Skip to content

Instantly share code, notes, and snippets.

@PrateekKumarSingh
Created July 11, 2019 18:23
Show Gist options
  • Save PrateekKumarSingh/516ef393dc534def73f333f5aabaf9c7 to your computer and use it in GitHub Desktop.
Save PrateekKumarSingh/516ef393dc534def73f333f5aabaf9c7 to your computer and use it in GitHub Desktop.
# Method 1 - Using PSTypeNames
$Alpha = [PSCustomObject]@{a=1; b=2}
$Alpha.pstypenames.Clear()
$Alpha.pstypenames.Add('Alpha')
$Alpha | Get-Member
# Method 2 - Using PSObject Adapter
$Beta = Get-Service BITS
$Beta.PSObject.TypeNames.Insert(0,'Beta')
$Beta | Get-Member
# Method 3 - Using Hashtable
$Gamma = [pscustomobject]@{
PSTypeName='Gamma'
Name = 'Prateek'
Age = 28
}
$Gamma | Get-Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment