Skip to content

Instantly share code, notes, and snippets.

View AspenForester's full-sized avatar

JB Lewis AspenForester

  • Hennepin County, MN, USA
  • Minnesota, USA
View GitHub Profile
@AspenForester
AspenForester / Show-ServerBootTime.ps1
Created May 16, 2014 16:12
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"