Powershell: Cast object inside select-object -


i want cast object inside select-object

i can't seem syntax right :(

select-object `                 @{name='a';expression={$path}}, `                 @{name='b';expression={$folder}}, `                 @{name='c';expression={ [system.security.principal.securityidentifier]$_.identityreference.translate([system.security.principal.ntaccount]).value}}, `                 @{name='sid';expression={$_.identityreference}} 

keep getting empty string.

any ideas?


edit: should have mentioned trying here. identityreference seems giving me sid, want convert name.

@briantist - yes cast works outside, try ([system.security.principal.securityidentifier]"s-1-5-xx-valid-sid-here").translate([system.security.principal.ntaccount]).value started with.

@tessellatingheckler $_.identityreference.translate([system.security.principal.securityidentifier])didn't work sadly.

can post bit more code?
works me:

select-object `             @{name='a';expression={$path}}, `             @{name='b';expression={$folder}}, `             @{name='c';expression={((new-object -typename system.security.principal.securityidentifier -argumentlist "sid").translate([system.security.principal.ntaccount])).value}}, `             @{name='sid';expression={$_.identityreference}} 


replace input.

-argumentlist "sid"


Comments