Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Get Displayname from samaccountname

$
0
0

Hey Gang,

 

Need some help I am trying to get the display name from Samaccount this is this what I have 

 

$user = Get-Content 'C:\Temp\User.txt'

 

$results = @()

 

Foreach($user in $Users)

 

{

$result +=Get-QADUser -Identity $User.Samaccountname | select displayname,Samaccountname

 

 

}

$result| Export-Csv C:\Temp\Test12.csv -notype

 

 

When I ran it I get nothing!!! No error MSG just back to the prompt.  I can run it as this

Get-Content 'C:\temp\User.txt'| %{Get-QADUser -Identity $_ | Select Displayname, SamAccountName}

and it works. But I would like to add some error checking so I can see  what user names are not valid. Please help me Thanks in advance 

Viewing all articles
Browse latest Browse all 6937

Trending Articles