이 문서는 Powershell을 통해 IIS 서비스를 실행 및 중지하는 스크립트에 대한 정보를 공유한다.
Website/Application Pool 실행
$sitename="IIS명"
Import-Module WebAdministration
if ((Get-WebAppPoolState -Name $sitename).Value -ne 'started'){
Write-Output ('start Application Pool: {0}' -f $sitename)
start-WebAppPool -Name " $sitename"
}
Import-Module WebAdministration
if ((Get-WebsiteState -Name $sitename).Value -ne 'started'){
Write-Output ('start Website: {0}' -f $sitename)
start-Website -Name " $sitename"
}
Website/Application Pool 중지
$sitename="IIS명"
Import-Module WebAdministration
if ((Get-WebsiteState -Name $sitename).Value -ne 'Stopped'){
Write-Output ('Stopping Website: {0}' -f $sitename)
Stop-Website -Name " $sitename"
}
if ((Get-WebAppPoolState -Name $sitename).Value -ne 'Stopped'){
Write-Output ('Stopping Application Pool: {0}' -f $sitename)
Stop-WebAppPool -Name " $sitename"
}