Skip to content

Instantly share code, notes, and snippets.

@lipkau
Last active October 19, 2015 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lipkau/f5279425f394a455ec75 to your computer and use it in GitHub Desktop.
Save lipkau/f5279425f394a455ec75 to your computer and use it in GitHub Desktop.
[BUG] Transform HashTable to Custom Object
Add-Type -TypeDefinition @"
using System;
namespace foo
{
public struct bar {
public Int64 id;
}
}
"@
[foo.bar]@{id=1}
@lipkau
Copy link
Author

lipkau commented Oct 12, 2015

Testing on a Win7 with Windows Management Framework 5.0 installed return the following:

powershell -Version 3.0 -NoProfile

PS C:\Users\a547333> Add-Type -TypeDefinition @"
>> using System;
>>
>> namespace foo
>> {
>>     public struct bar {
>>         public Int64 id;
>>     }
>> }
>> "@
>>
PS C:\Users\a547333> [foo.bar]@{id=1}

id
--
 0

powershell -Version 4.0 -NoProfile

PS C:\Users\a547333> Add-Type -TypeDefinition @"
>> using System;
>>
>> namespace foo
>> {
>>     public struct bar {
>>         public Int64 id;
>>     }
>> }
>> "@
>>
PS C:\Users\a547333> [foo.bar]@{id=1}

id
--
 0

powershell -Version 5.0 -NoProfile

PS C:\Users\a547333> Add-Type -TypeDefinition @"
>> using System;
>>
>> namespace foo
>> {
>>     public struct bar {
>>         public Int64 id;
>>     }
>> }
>> "@
>>
PS C:\Users\a547333> [foo.bar]@{id=1}

id
--
 0

@lipkau
Copy link
Author

lipkau commented Oct 12, 2015

Testing on a Win7 with Windows Management Framework 4.0 installed return the following:

2015-10-12_125145

@lipkau
Copy link
Author

lipkau commented Oct 19, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment