Удаление пользователей по списку из Active Directory с помощью Powershell

Задача — удалить 100500 юзеров из Active Directory:

##### Содержимое Users.txt #####
# dadrianovskiy
# divanov
# vyurov
# dkishinevskiy
# ........
########################

Import-Module Activedirectory
$users = Get-Content ".\Users.txt"

##### Удаление пользователей по списку #####
ForEach ($remove in $users)
{ write-host $remove "Deleted"
Start-Sleep -s "2"
  Remove-ADUser -Identity $remove -Confirm:$false
}

Добавить комментарий

Ваш адрес email не будет опубликован.