Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.