PSTypenames for a string object

by Grzegorz Kulikowski

PS C:\> $myobj = ‘2222’
PS C:\> $myobj.pstypenames
System.String
System.Object
PS C:\> $myobj.pstypenames.add(‘Greg’)
PS C:\> $myobj.pstypenames
System.String
System.Object
PS C:\> [psobject]$myobj2=’2222′
PS C:\> $myobj2.pstypenames.add(‘Greg’)
PS C:\> $myobj2.pstypenames
System.String
System.Object
Greg

 

You have to cast them to PSO first, as it was explained to me on #powershell-help that the string PSO do not propagate members, hence you have to make it manually

Advertisements

You may also like

Leave a Reply

Chinese (Simplified)DutchEnglishFrenchGermanHindiPolishRussianSpanish