Check and up pool IIS
12 de dezembro de 2022 | by administrador
# Load IIS module:
Import-Module WebAdministration
# SET AppPool Name
$AppPoolName = "DefaultAppPool"
#Testing if a String is NULL or EMPTY.
if ([string]::IsNullOrWhiteSpace($AppPoolName))
{
Write-Output "$AppPoolName does not exist"
}
else
{
try {
#Determines whether all elements of a file or directory path exist.
if (Test-Path IIS:\AppPools\$AppPoolName){
# Start App Pool if stopped else restart
#Get the runtime state of the DefaultAppPool and checking the status
if ((Get-WebAppPoolState($AppPoolName)).Value -eq "Stopped"){
Write-Output "Starting IIS app pool"
#starting the App Pool
Start-WebAppPool $AppPoolName
}
else {
Write-Output "Application pool is Running successfully"
}
}
}
catch {
Write-Output $_.Exception.Message
throw
}
}