There is a command:

whoami / USER

I need to parse the username and SID, i.e. there must be a string containing it. There is an option to output the result in CSV format (whoami / USER / FO CSV), only here Import-CSV accepts the file name, not the string. What possible solutions exist for this task?

  • Why parse the output if Powershell already produces objects ? - VladD

1 answer 1

only Import-CSV accepts the file name, not the string

ConvertFrom-Csv has not been canceled yet, but I would do it differently:

 $SecurityIdentifier = [System.Security.Principal.WindowsIdentity]::GetCurrent().User $NTAccount = $SecurityIdentifier.Translate([System.Security.Principal.NTAccount]) $NTAccount.Value $SecurityIdentifier.Value