Bulk Activation Script

#Activate or reactivate a list of users from a CSV file that includes the SamAccountName and their initial password

$csvPath = "C:\Users\Public\Documents\Rotators.csv"  

   

$targetOU = "OU=<obfuscated>,OU=<obfuscated>,DC=<obfuscated>,DC=<obfuscated>,DC=<obfuscated>"  

  

$newNote = "<obfuscated>"  

 

$Description = "<obfuscated>"  

  

$JobTitle = "<obfuscated>"  

  

$users = Import-Csv -Path $csvPath  

foreach ($userRecord in $users) {  

$user = $userRecord.Username  

   

$currentNotes = (Get-ADUser $user -Properties info).info  

    

           $updatedNotes = "$currentNotes`r`n$newNote"  

  

             Set-ADUser $user -Replace @{info = $updatedNotes}  

  

          Set-ADUser –Identity $user –Description $Description  

  

          Set-ADUser –Identity $user –Replace @{title=$JobTitle}  

  

          Set-ADAccountPassword –Identity $user –Reset –NewPassword (ConvertTo-SecureString –AsPlainText $userRecord.NewPassword –Force)  

  

          Enable-ADAccount –Identity $user  

   

          Move-ADObject -Identity (Get-ADUser $user).DistinguishedName -TargetPath $targetOU  

 

Write-Output "Provisioning process completed for $user"  

  }