Link to home
Start Free TrialLog in
Avatar of nav2567
nav2567Flag for United States of America

asked on

bulk check and disable user accounts in AD.

Hello,

We have a list of user first and last names in separate columns in a CSV file.

Would someone advise a PS command to read this CSV file and return another file that contain their first and last names, account status (account disable or enable) and UPN names?  

We also need a PS command to disable these UPN names if they are currently enabled.  

Thanks.
Avatar of arnold
arnold
Flag of United States of America image

https://technet.microsoft.com/en-us/library/ee176874.aspx
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-csv?view=powershell-5.1
http://ps1scripting.blogspot.com/2012/07/powershell-working-with-csv-files.html
$handler=import-csv file.csv
foreach ($item in $handler) {
 $item.columnname1 

Open in new window


You have to see a step at a time on whether the data ....

https://technet.microsoft.com/en-us/library/ee617197.aspx

you want to scan the AD and then based on the CSV deactivate if needed, or reactivate if disabled...


Look at MS powershell 5.1 link it includes references that may have scripts that do what you are looking for potentially need to be slightly adapted to the specific scenario that you have.
OK so to get this right 1) you have a list of users 2) they or may not be disabled 3) if they are disabled do nothing 4) if enabled then disable if that what you want?
SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Script will do as requested, but good idea to look at gui ad tools as well if your not comfortable using scripts.