Good night guys!
Need a little help!
I made a script to disable users in the ad but I need to make an if and else to take the test within a file .csv whether or not hesitate in AD and disable.
Add-PSSnapin Quest.ActiveRoles.ADManagement
Import-Module ActiveDirectory
$UsersToDisbableList=IMPORT-CSV C:\users.csv
Get-Credential -Credential avista\adm
Connect-QADService -service $PrimaryDC
Function DisableUsers
{
Param(
[string] $_SamAccountName
)
Get-ADUser -filter { DisplayName -eq $_SamAccountName } | Set-ADUser -Enabled $false
write-host ("Usuario: $_SamAccountName [Inactive]")
Start-Sleep -s 2
}
FOREACH ($User in $UsersToDisbableList) {
DisableUsers $User.SamAccountName
}