Skip to content

Instantly share code, notes, and snippets.

@RickyLin
Last active January 28, 2018 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RickyLin/2e29c24ee9a1ec6a6ba444da02672389 to your computer and use it in GitHub Desktop.
Save RickyLin/2e29c24ee9a1ec6a6ba444da02672389 to your computer and use it in GitHub Desktop.
Powershell script to start an IIS Application Pool
# 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