PSTypenames for a string object


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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s