Powershell – Check Client Machine Uptime


Want to check the last time all of your client machines booted in a particular OU?. Well here is a nice little two liner to do so.

$SearchBase = Get-ADComputer -SearchBase "OU=OUTARGET,DC=YOURDOMAIN,DC=YOURDOMAIN" -Filter * | ForEach-Object (Write-Output {$_.name})
Get-CimInstance -ComputerName $SearchBase -ClassName win32_operatingsystem -ErrorAction SilentlyContinue | select pscomputername, lastbootuptime, Description | Sort-Object -Property lastbootuptime -Descending | Out-GridView

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s