Advertisement
IsraelTorres

killADUser.ps1

Mar 15th, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Israel Torres
  2. # 2012-03-14
  3. # Kills AD User from AD [WARNING USER IS DELETED]
  4. Import-Module ActiveDirectory
  5. #
  6. # args: username, security group
  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 "Killing User:$username!"
  13.             Remove-ADUser -Identity $username -Confirm:$false
  14.     }
  15. }else{
  16.     Write-Host "Usage: .\killADUser.ps1 username"
  17. }
  18. #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement