\n Hi, and welcome to the PowerShell forum! \n\n\nDon’t apologize for being a “noob” or “newbie” or “n00b.” There’s just no need – nobody will think you’re stupid, and the forums are all about asking questions. Just ask!\nUse a descriptive subject. Don't say \"Need help\" or \"PowerShell Help\", actually summarize what the problem is. It helps the rest of us keep track of which problem is which.\nDon’t post massive scripts. We’re all volunteers and we don’t have time to read all that, nor will we copy, past…\n <\/blockquote>\n<\/aside>\n\n <\/p>","upvoteCount":0,"datePublished":"2018-09-11T16:23:23.000Z","url":"https://community.spiceworks.com/t/ps-script-help/672568/3","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"
try like so, but as said, it depends on your CSV file.<\/p>\n
Import-Module ActiveDirectory\n\n$users = Import-CSV \"c:\\location\\of\\file.csv\"\n\nforeach ($user in $users) {\n\n $gname = $user.givenname\n $sname = $user.surname\n\n if ($gname -and $sname) {\n get-aduser -filter \"givenname -eq '$gname' -and surname -eq '$sname'\" -properties * | \n select samaccountname, emailaddress\n }\n else {\n Write-Warning \"no name info\"\n }\n}\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2018-09-11T16:25:47.000Z","url":"https://community.spiceworks.com/t/ps-script-help/672568/4","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":" <\/p>","upvoteCount":0,"datePublished":"2018-09-11T16:34:55.000Z","url":"https://community.spiceworks.com/t/ps-script-help/672568/5","author":{"@type":"Person","name":"rekin","url":"https://community.spiceworks.com/u/rekin"}},{"@type":"Answer","text":"
JitenSh,<\/p>\n
Thanks.<\/p>","upvoteCount":0,"datePublished":"2018-09-17T16:01:00.000Z","url":"https://community.spiceworks.com/t/ps-script-help/672568/7","author":{"@type":"Person","name":"rekin","url":"https://community.spiceworks.com/u/rekin"}}]}}
Neally
(Neally)
September 11, 2018, 4:23pm
3
If you post code, please use the ‘Insert Code’ button. Please and thank you!
Hi, and welcome to the PowerShell forum!
Don’t apologize for being a “noob” or “newbie” or “n00b.” There’s just no need – nobody will think you’re stupid, and the forums are all about asking questions. Just ask!
Use a descriptive subject. Don't say "Need help" or "PowerShell Help", actually summarize what the problem is. It helps the rest of us keep track of which problem is which.
Don’t post massive scripts. We’re all volunteers and we don’t have time to read all that, nor will we copy, past…