Skip to content

Instantly share code, notes, and snippets.

@jaredcatkinson
Created April 30, 2018 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jaredcatkinson/7c4a0ff7052d214b2e2744035d34cf62 to your computer and use it in GitHub Desktop.
Save jaredcatkinson/7c4a0ff7052d214b2e2744035d34cf62 to your computer and use it in GitHub Desktop.
Update-TypeData -TypeName Object -MemberType ScriptMethod -MemberName SizeOf -Value {
param()
if($this -is [type]) {
$SizeOf = [System.Runtime.InteropServices.Marshal].GetMethod('SizeOf',[type[]]@([type]))
}
else {
$SizeOf = [System.Runtime.InteropServices.Marshal].GetMethod('SizeOf',[type[]]@([Object]))
}
return $SizeOf.Invoke($null,@($this.psobject.BaseObject))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment