I have the following line of code...
get-wmiobject -class win32_computersystem | select-object username
It returns (redacted with placeholders)...
@{username=DOMAIN\jsmith}
What needs to be done to remove the padding and give me a "plain" readout of DOMAIN\jsmith
?
For bonus points, how do I parse that value into just jsmith
?
You need to expand the property to get the value of
username
instead of a custom object with the propertyusername
. TryTo get the username only, try:
You may need to use
[1]
instead of[2]
at the end depending on your OS. In Windows 8, you need2
, while in Windows 7(and older I think), you need1
.try this