search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Posted in Windows Powershell, Windows Server | No Comment | 3,307 views | 03/07/2014 11:34

You can use following script to get pwdlastset value of a computer:

1
[datetime]::fromfiletime((Get-ADComputer SLESGTRM04 -Properties pwdlastset).pwdlastset)

Also you can use conditional query:

1
2
$RefDate = (Get-Date).AddDays(-90)
Get-ADComputer -Filter * -Properties pwdlastset | Where {[datetime]::fromfiletime($_.pwdlastset) -lt $RefDate}

If you want to filter workstations:

1
2
$RefDate = (Get-Date).AddDays(-90)
Get-ADComputer -Filter * -Properties pwdlastset,OperatingSystem | Where OperatingSystem -like "*Server*" | Where {[datetime]::fromfiletime($_.pwdlastset) -lt $RefDate}

I hope you will find it helpful. Script should run on Windows Server 2012 and later..