Hello,
I am very new to powershell and I am having an issue when trying to use the get Get-QADUser command to Querey AD for a users full name (DisplayName). The querey is based off a list of usernames from an imported .csv file that contains a few blank cell's in the Column where the username should be. If I manually filter out these blank cell's I am able to get the querey just fine. Is there a way I can have the script just ignore all the blank cell's and move on to the next cell without erroring out? Additionally I would like to have the results of the querey update the FullUserName column with the users full name. I know powershell can do all this for me, I just need to figure out how to get it done.
Thank you,
Aaron
Imported .CSV that contains usernames and other fields
| GroupName |
Name |
AssignedUserName |
FullUserName |
| Test-XenDesktop-Group |
Test1 |
testuser1 |
|
| Test-XenDesktop-Group |
Test2 |
testuser2 |
|
| Test-XenDesktop-Group |
Test3 |
|
|
| Test-XenDesktop-Group |
Test4 |
|
|
| Test-XenDesktop-Group |
Test5 |
testuser3 |
|
| Prod-XenDesktop-Group |
Prod1 |
|
|
| Prod-XenDesktop-Group |
Prod2 |
produser1 |
|
| Prod-XenDesktop-Group |
Prod3 |
produser2 |
|
| Prod-XenDesktop-Group |
Prod4 |
|
|
| Prod-XenDesktop-Group |
Prod5 |
produser3 |
|
Here is my code:
Add-PSSnapin Quest.ActiveRoles.ADManagement
$Usernames = Import-Csv E:\scripts\Usernames.csv
$Usernames | foreach-object{
$DisplayName = Get-QADUser -identity $_.AssignedUserName
$DisplayName | Select-Object DisplayName
}