Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, June 29, 2016 6:41 PM
I have a csv of just display names with a header of "users", and I need to determine whether they are still enabled in AD.
Id like to do something like this:
Import-CSV C:\xfer\tokenusers.csv | Foreach-Object {
get-aduser -displayname $_.users | Select Name, SamAccountName,Enabled
} | export-csv C:\xfer\output1.csv -notype
however I am unable to get it to work. I know its related to the -displayname $_.users part of the script, however I am unable to figure out a solution.
Thank You,
Jake
All replies (6)
Thursday, July 7, 2016 11:48 AM ✅Answered
Import-CSV C:\xfer\tokenusers.csv | Foreach-Object {
Get-ADUser -Filter "Displayname -eq '$($_.users)'" | Select Name, SamAccountName,Enabled
}
Thursday, July 7, 2016 11:51 AM ✅Answered
Yes.. Use Export-Csv & use -Append Parameter
Wednesday, June 29, 2016 6:47 PM
Get-ADUser does not have a -DisplayName parameter. Use -Filter instead.
https://technet.microsoft.com/en-us/library/ee617241.aspx
Thursday, July 7, 2016 11:30 AM
Thank You Mike,
I am not great with the -filter parameter, Would you be willing to give an example of how I need to write it out in order to accomplish what I need?
Thursday, July 7, 2016 11:49 AM
Awesome, Thank You Vincent. And then I can just pipe that into a export-csv right?
Thursday, July 7, 2016 12:02 PM
Thank you so much Vincent. That worked.