简体   繁体   中英

IIS Recycling Powershell Deploy; Code Not Changing Settings

So I'm wondering what's going on. The code doesn't report any errors and all signs point to success, but the "Virtual Memory Limit" doesn't seem to change and the

"Get-itemProperty" for Recycling.periodicRestart.Memory also doesn't seem to change it's value.

I'm executing this on a domain admin. It can change recycling.periodicRestart.schedule.collection no problem using the same script.

Anyway, here's the script, do you see any reason why that wouldn't be working?

    $Cred = Get-Credential -UserName DOMAIN\admin -Message 'Enter Password'
$servers = @("WEB-SERVER-1","WEB-SERVER-2","WEB-SERVER-3")
foreach ($server in $servers) {
    write-host $server
    Invoke-Command -ComputerName $server -Credential $cred {
    import-module WebAdministration
    Set-ItemProperty IIS:\AppPools\* -Name Recycling.periodicRestart.Memory -Value 0
    Get-ItemProperty -Path IIS:\AppPools\* -name Recycling.periodicRestart.Memory | fl value
    }
}

Here is the script that WORKS to set the value of PeriodicRestart.Schedule.Collection

        $Cred = Get-Credential -UserName DOMAIN\admin -Message 'Enter Password'
    $servers = @("WEB-SERVER-1","WEB-SERVER-2","WEB-SERVER-3")
    foreach ($server in $servers) {
        write-host $server
        Invoke-Command -ComputerName $server -Credential $cred {
        import-module WebAdministration
    Set-ItemProperty IIS:\Sites\* -name recycling.periodicRestart.schedule.collection -value @{"01:00:00","12:00:00"}
    Get-ItemProperty -Path IIS:\AppPools\* -name recycling.periodicRestart.schedule.collection | fl value
    }
}

Yo could use below command to recycle an application based on Virtual Memory Limit:

PS C:\windows\system32>  import-module WebAdministration

PS C:\windows\system32> Set-ItemProperty IIS:\AppPools\test -Name Recycling.periodicRestart.memory -Value 11

PS C:\windows\system32> Set-ItemProperty IIS:\AppPools\* -Name Recycling.periodicRestart.memory -Value 11

在此输入图像描述

Regards, Jalpa

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM