Run this command
$sname = get-aduser $sam -properties * | select surname
Results is
surname
smith
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
js2010
3
Probably the most common powershell question.
That worked great
Thank you
This can be marked resolved
Or reference the property:
(get-aduser user1 | select Surname).Surname
js2010
6
(get-aduser user1).surname
get-aduser | % surname