I want to start and stop application pool in IIS using powershell script. I had try to write the script but i didn\'t get this.
You can use this
if your use (PowerShell 2.0) import WebAdministration module
import-module WebAdministration
Please check the state of the application pool before. If the application pool is already stopped you get an exception.
Stop application pool:
$applicationPoolName = 'DefaultAppPool'
if((Get-WebAppPoolState -Name $applicationPoolName).Value -ne 'Stopped'){
Write-Output ('Stopping Application Pool: {0}' -f $applicationPoolName)
Stop-WebAppPool -Name $applicationPoolName
}
Start application pool:
if((Get-WebAppPoolState -Name $applicationPoolName).Value -ne 'Started'){
Write-Output ('Starting Application Pool: {0}' -f $applicationPoolName)
Start-WebAppPool -Name $applicationPoolName
}
Permissions: You have to be a member of the "IIS Admins" group.