$(New-Object System.Security.Principal.NTAccount("Students")).Translate([System.Security.Principal.SecurityIdentifier]).Value
Existe alguma maneira de fazer o seguinte sem criar o objeto $ obj?
$obj = New-Object System.Security.Principal.NTAccount("Students") ; $obj.Translate([System.Security.Principal.SecurityIdentifier]).Value
Eu tentei canalizar assim:
New-Object System.Security.Principal.NTAccount("Students") | $_.Translate([System.Security.Principal.SecurityIdentifier]).Value
mas obteve o seguinte erro:
Expressions are only allowed as the first element of a pipeline.
At line:1 char:128
+ New-Object System.Security.Principal.NTAccount("Students") | $_.Translate([System.Security.Principal.SecurityIdentifi
er]).Value <<<<
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline
Obrigado antecipadamente!
Se você quiser continuar usando o pipeline, use o cmdlet ForEach-Object.
New-Object System.Security.Principal.NTAccount("Students") | ForEach-Object {
$_.Translate([System.Security.Principal.SecurityIdentifier]).Value)
}
Tags windows powershell