Last active
January 28, 2018 11:17
-
-
Save RickyLin/2e29c24ee9a1ec6a6ba444da02672389 to your computer and use it in GitHub Desktop.
Powershell script to start 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: StartAppPool.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 "Stopped") | |
{ | |
Start-WebAppPool -Name $AppPoolName | |
Write-Output "$($AppPoolName) started." | |
} | |
else | |
{ | |
Write-Output "$($AppPoolName) has already started." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment