Store username of system [duplicate]
问题 This question already has an answer here : Pull NT user ID from powershell (1 answer) Closed 15 hours ago . Currently I use this to get the username of the remote system: Get-WmiObject win32_computersystem -Computer $tag1 | Format-Table -Property @{Name="Username";Expression={$_.username}} -Autosize; This will output: Username -------- GHS_NTDOMAIN\AJSTEPANIK I want to store the AJSTEPANIK part to a variable so I can use it in another part of the script, but I am unsure how to trim it or if