Hello,
I’m pretty new to powershell scripting but I’m trying to disable all the users on a csv I created. The csv file contains the SAM account names and the script I found here on this subreddit correctly iterates through the list but it fails to disable the accounts. It looks like its failing to because its looking for the user in the root OU: “DC=[companyname],DC=com”. I’m at my wits end and I’d really rather not disable/move 100+ users.
My question is, how do I get this script to iterate through every OU within the user OU? We have a ton of locations. The script I’m referring to is:
Import-Module activedirectory
$list = Import-CSV c:scriptsdisableusers.csv
forEach ($item in $list) {
$samAccountName = $item.samAccountName
Disable-ADAccount -Identity $samAccountName
}
submitted by /u/wild8900
[link] [comments]
The post CSV Batch Account Disable appeared first on How to Code .NET.