feat(scripts): added in iis contorls
This commit is contained in:
46
scripts/iisControls.ps1
Normal file
46
scripts/iisControls.ps1
Normal file
@@ -0,0 +1,46 @@
|
||||
param (
|
||||
[string]$ServerName,
|
||||
[string]$AppPoolName,
|
||||
[string]$StopOrStart
|
||||
)
|
||||
|
||||
write-host $StopOrStart
|
||||
if ($StopOrStart -eq "stop") {
|
||||
Invoke-Command -ComputerName $ServerName -Credential $cred -ScriptBlock {
|
||||
param($AppPoolName)
|
||||
|
||||
Import-Module WebAdministration
|
||||
Write-Host "Stopping AppPool '$AppPoolName' on $($env:COMPUTERNAME)"
|
||||
|
||||
try {
|
||||
Stop-WebAppPool -Name $AppPoolName -ErrorAction Stop
|
||||
|
||||
Start-Sleep -Seconds 2
|
||||
$state = (Get-WebAppPoolState -Name $AppPoolName).Value
|
||||
Write-Host "Result: $state"
|
||||
} catch {
|
||||
Write-Error $_.Exception.Message
|
||||
exit 1
|
||||
}
|
||||
} -ArgumentList $AppPoolName
|
||||
}
|
||||
|
||||
if ($StopOrStart -eq "start"){
|
||||
Invoke-Command -ComputerName $ServerName -Credential $cred -ScriptBlock {
|
||||
param($AppPoolName)
|
||||
|
||||
Import-Module WebAdministration
|
||||
Write-Host "Starting AppPool '$AppPoolName' on $($env:COMPUTERNAME)"
|
||||
|
||||
try {
|
||||
Start-WebAppPool -Name $AppPoolName
|
||||
Start-Sleep -Seconds 2
|
||||
$state = (Get-WebAppPoolState -Name $AppPoolName).Value
|
||||
Write-Host "Result: $state"
|
||||
} catch {
|
||||
Write-Error $_.Exception.Message
|
||||
exit 1
|
||||
}
|
||||
} -ArgumentList $AppPoolName
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user