Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
10 lines (7 sloc) 394 Bytes
Import-Module ActiveDirectory
function Get-StaleComputers() {
$time = (Get-Date).Adddays(-30)
Get-ADComputer -Filter { LastLogonTimeStamp -lt $time } -Properties LastLogonTimeStamp | Select-Object Name,@{Name="Stamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}} # | Export-CSV C:\temp\unused_machines.csv -notypeinformation
Write-Host done.
You can’t perform that action at this time.