Welcome › Forums › General PowerShell Q&A › GET-ADUSER output issue
Run this command
$sname = get-aduser $sam -properties * | select surname
This is an object surname ______ smith how to output just smith?
I need to feed this to another command and the surname ____ give the command a problem.
To get the string, you can use -ExpandProperty so that $sname = smith:
$sname = get-aduser $sam -properties * | select -ExpandProperty surname
Probably the most common powershell question.
That worked great
This can be marked resolved
Or reference the property:
(get-aduser user1 | select Surname).Surname
get-aduser | % surname