IsraelTorres

DisableADUser.ps1

Mar 15th, 2012
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Israel Torres
  2. # 2012-03-14
  3. # Disable an AD user in AD
  4. Import-Module ActiveDirectory
  5. #
  6. # args: username
  7. if($args.Length -eq 1){
  8. $username = $args[0]
  9.     if (!(Get-ADUser -filter {SamAccountName -eq $username})) {
  10.             Write-Host "User: $username does not exist; run .\CreateADUser.ps1 username password."        
  11.     }else{
  12.             Write-Host "Disabling User:$username"
  13.             Disable-ADAccount -Identity $username
  14.     }
  15. }else{
  16.     Write-Host "Usage: .\DisableADUser.ps1 username"
  17. }
  18. #EOF
RAW Paste Data