Announcement

Collapse
No announcement yet.

Disabling users in AD with powershell script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Disabling users in AD with powershell script

    Hi,

    I am looking for a script that will disable users (from a csv file) and at the same time write "User disabled, contact John Doe" in the description field.

    My csv file looks like this:

    Username
    Warren Buffet
    Bill Gates
    Bruce Willis
    Sylvester Stallone

    Thanks in advance.

  • #2
    Re: Disabling users in AD with powershell script

    Hi
    you can try this

    $File = Import-Csv -Path "c:\list.csv"
    foreach ($d in $file){
    Set-ADUser -Identity $d.Identity.Trim() -Enabled $False -Description "User disabled, contact John Doe"
    }
    Write-Host "Done....." -BackgroundColor Green -ForegroundColor Black

    CSV file should be like this

    Identity
    LoginID1
    LoginID2
    LoginID3
    LoginID4

    Comment

    Working...
    X