Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Users by Last name with Get-AdUser

$
0
0

Awesome Scripters,

   I'm still pretty rookie, but learning.  Could you please let me know what you think here and see if I'm doing something incorreclty or let me know why the return value is not solid.

Object:  Pull SAMAccountName from listed user list (Answer file)

_______

$Users = GC C:\temp\users.txt

ForEach($User in $Users){

echo $User

echo __________

get-aduser -f {Surname -like '$User'} | Format-Table Name, SamAccountName

}

-----

Return value looks like:

Schmucateli

__________

Name                                                        SamAccountName
----                                                        --------------
$Ramp.UserTemplate                                          rusrtmp

Swartz

__________

Name                                                        SamAccountName
----                                                        --------------
$Ramp.UserTemplate                                          rusrtmp

So what am I doing wrong?  Sorry and thanks

J


Viewing all articles
Browse latest Browse all 15028

Trending Articles