Created
January 28, 2018 11:18
-
-
Save RickyLin/0fe4965eb4ce40cc1a43c02adba4d1ee to your computer and use it in GitHub Desktop.
Powershell script to stop an IIS Application Pool
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: StopAppPool.ps1 -AppPoolName DefaultAppPool | |
# set-executionpolicy remotesigned | |
# Document of WebAdministration: | |
# https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee790599(v%3dtechnet.10) | |
# multiple parameters sample: param([string]$paramA,[string]$paramB) | |
param([string]$AppPoolName) | |
if ([string]::IsNullOrEmpty($AppPoolName)) | |
{ | |
throw "Parameter AppPoolName is required." | |
} | |
Import-Module WebAdministration | |
$AppPoolState = Get-WebAppPoolState -Name $AppPoolName | |
if ($AppPoolState.Value -eq "Started") | |
{ | |
Stop-WebAppPool -Name $AppPoolName | |
Write-Output "$($AppPoolName) stopped." | |
} | |
else | |
{ | |
Write-Output "$($AppPoolName) has already been stopped." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment