feat(scripts): added in iis contorls

This commit is contained in:
2025-07-16 06:48:43 -05:00
parent 73600055fc
commit 9bd6e1fc04

46
scripts/iisControls.ps1 Normal file
View 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
}