Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Find all the application pools that are stopped in IIS and restart
WhatsApp
Dorababu Meka
Jul 19
2016
1.4
k
0
1
function RestartApplicationPool
{
Clear-Host
$webapps = Get-WebApplication
[
string
] $list = @()
foreach
($WebAppPools
in
get
-childitem IIS:\AppPools\)
{
$name =
"IIS:\AppPools\"
+ $WebAppPools.name
$item = @{}
$item.WebAppName = $WebAppPools.name
$item.State = (Get-WebAppPoolState -Name $WebAppPools.name).Value
if
($item.State -eq
'Stopped'
)
{
Start-WebAppPool -Name $WebAppPools.name
#$obj = New-Object PSObject -Property $item
$list += $WebAppPools.name
$list+=
" and "
}
}
if
($list.Length -gt 0)
{
$list = $list.Remove( $list.Length - 4, 4 )
}
if
($list.Length -gt 0) {
Write-Host
"Successfully restared the following "
$list -ForegroundColor Green
}
else
{
Write-Warning
"No application pools found to restart"
}
}
RestartApplicationPool
PowerShell
IIS
Application pools
Up Next
Find all the application pools that are stopped in IIS and restart