Skip to content

Instantly share code, notes, and snippets.

@crshnbrn66
Created November 13, 2015 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crshnbrn66/33bd287a8f9cf84ea1bb to your computer and use it in GitHub Desktop.
Save crshnbrn66/33bd287a8f9cf84ea1bb to your computer and use it in GitHub Desktop.
Get the last time app pool was Restarted.
function get-webApppoolstatus($pool)
{
$poolReturn = @()
$poolStatus = gwmi win32_process -filter "Name like '%w3wp%'" | select name, Processid, commandline, creationdate
#$poolstatus.converttodatetime($poolStatus.creationdate)
foreach($status in $poolStatus)
{
if(($status.commandline) -like "*$pool*" -and ($pool -ne $null))
{
$status.creationdate = [System.Management.ManagementDateTimeConverter]::ToDateTime($status.creationdate)
$poolReturn = $status
}
elseif($pool -eq $null)
{
$status.creationdate = [System.Management.ManagementDateTimeConverter]::ToDateTime($status.creationdate)
$poolReturn += $status
}
}
return $poolReturn
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment