February 2010
S M T W T F S
« Nov   Mar »
 123456
78910111213
14151617181920
21222324252627
28  

Google Ads

Thomas' Photography

Mardi GrasSpainKidsCemeteries

Remove Old Computer Accounts

We recently upgraded to Windows 2008R2 Native Mode. As a result we now have a lot of PowerShell functionality in AD without using the Quest cmdlets. They were great while we needed them but I like having the native functionality.

I blogged about how to do this from the command line using dsquery and dsrm here. That solution works very well, however I have other PS scripts I would like to integrate this with so I did it now natively in PS.

$date = [DateTime]::Today.AddDays(-90); Get-ADComputer -Filter ‘PasswordLastSet -lt $date’ -Properties PasswordLastSet | sort Name | remove-adobject -confirm:$false –Recursive

 

I pulled this from the PowerShell AD blog I think so I have to give them original credit. I made slight modifications for my environment…

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>