IIS 应用程序池 PowerShell 脚本更改高级属性的方法

## IIS WebAdmin Module
    Import-Module WebAdministration

    $AppPool = "mqttService(8011)"
    $Site = "mqttService(8011)"
    $AppPoolInstance = Get-Item IIS:\AppPools\$AppPool

    Write-Output "Set Site PreLoadEnabled to true"
    Set-ItemProperty IIS:\Sites\$Site -name applicationDefaults.preloadEnabled -value True

    Write-Output "Set Recycling.periodicRestart.time  = 0"
    $AppPoolInstance.Recycling.periodicRestart.time = [TimeSpan]::Parse("0");
    $AppPoolInstance | Set-Item

    Write-Output "Set App Pool start up mode to AlwaysRunning"
    $AppPoolInstance.startMode = "alwaysrunning"

    Write-Output "Set App Pool enable 32b to true"
    $AppPoolInstance.enable32BitAppOnWin64 = [Boolean]::Parse("True");

    Write-Output "Disable App Pool Idle Timeout"
    $AppPoolInstance.processModel.idleTimeout = [TimeSpan]::FromMinutes(0)
    $AppPoolInstance | Set-Item

    if ($appPoolStatus -ne "Started") {
        Write-Output "Starting App Pool"
        Start-WebAppPool $AppPool
    } else {
        Write-Output "Restarting App Pool"
        Restart-WebAppPool $AppPool
    }

 

这是一个持续运行,不回收,32位的服务程序的应用程序池高级属性设置

以下是执行.ps1脚本的步骤:

管理员身份运行 Windows PowerShell
执行“Set-ExecutionPolicy RemoteSigned -Scope CurrentUser”,选“y”
找到部署包根目录,执行“.\StartMqttService.ps1”
执行“Set-ExecutionPolicy RemoteSigned -Scope CurrentUser”,选“n”

 

posted @ 2023-06-01 16:09  你好创造者  阅读(44)  评论(0编辑  收藏  举报