I need to catch the follow error that is currently being outputted:
ERROR ( hresult:80070425, message:Command execution failed.) The service cannot accept control messages at this time.
From my PowerShell script snippet, which is not catching the error currently:
Try{
appcmd start apppool /apppool.name:DefaultAppPool
}Catch{
#$ErrorMessage = $_.Exception.Message
#$FailedItem = $_.Exception.ItemName
Write-Host "AppPool cannot start." -BackgroundColor Red
}
Am I missing something? I would like the error message to be as specific as possible. If it helps, this is IIS8.5. I've referenced these links: 1 | 2 | 3 | 4 | 5 |