Solved

Disable multiple AD accounts with powershell

Posted on 2015-01-15
2
106 Views
Last Modified: 2015-01-29
hi EE

Can someone please help me modify this so the script also disables the accounts .
The script should the disable the accounts and add the note.

GC Users.txt | % {
$note = (Get-ADUser $_ -Properties info).info
$info = "Disabled- 01/15/2014-Last Logon Greater then 90 days "
If ($note -ne $null){
Set-ADUser $_ -replace @{info="$note`r`n$info"}
}Else{
Set-ADUser $_ -replace @{info=$info}
}
}
0
Comment
Question by:MilesLogan
2 Comments
 
LVL 28

Accepted Solution

by:
becraig earned 500 total points
Comment Utility
I am assuming you want to disable and simply append if a note already exists:

Disable Ad Account should do that for you

GC Users.txt | % {
$uid = $_
$note = (Get-ADUser $_ -Properties info).info
$info = "Disabled- 01/15/2014-Last Logon Greater then 90 days "
If ($note -ne $null){
Set-ADUser $_ -replace @{info="$note`r`n$info"}
Disable-ADAccount -Identity $uid
}Else{
Set-ADUser $_ -replace @{info=$info}
Disable-ADAccount -Identity $uid
}
} 

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
Comment Utility
Sorry ..  I thought I had closed this out .. thank you!
0

Featured Post

Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

Join & Write a Comment

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now