Skip to content

Instantly share code, notes, and snippets.

@AspenForester
Created May 16, 2014 16:12
Show Gist options
  • Save AspenForester/c07d27c265453cd59c9c to your computer and use it in GitHub Desktop.
Save AspenForester/c07d27c265453cd59c9c to your computer and use it in GitHub Desktop.
Powershell to create a grid view of Server boot times. This is just a quick and dirty script (its really just a long one-liner), needs to be redeveloped into a more reusable tool.
# requires -version 3.0
$filter = {((name -notlike "*d") -and (name -notlike "*q")) -and ((name -notlike "dev*") -and (name -notlike "vdev*"))}
$SB = "OU=Servers,OU=Computers,OU=MyLocale,OU=MyDataCenterr,OU=NA,DC=foo,DC=local"
Get-ADComputer -filter $filter -SearchBase $SB -SearchScope Subtree |
where {(Test-Connection -ComputerName $_.name -Count 1 -Quiet)} |
% { Get-WmiObject -Class win32_operatingsystem -computername $_.name -Verbose} |
select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} |
#Sort-Object -Property LastBootUpTime
Out-GridView -Title "Production Servers"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment