简体   繁体   中英

User PowerShell to get IIS Recycling Time For Remote Server

I'm trying to create a script to audit the IIS recycling times on a number of remote servers. The script I'm attempting is:

$scriptBlock = {
import-module webadministration
Get-itemproperty -Path IIS:\AppPools\WebPage -Name recycling.periodicRestart.schedule.collection}
invoke-command -computername HOSTNAME -ScriptBlock $scriptBlock

Unfortunately, this is returning absolutely nothing. Any idea what I might be doing wrong?

You are not doing anything wrong, assuming you want to query the "DefaultAppPool," what you are doing will return empty if there is no value in the collection:

Get-ItemProperty -Path IIS:\AppPools\DefaultAppPool -Name recycling.periodicRestart.schedule.collection

Set it with:

Set-ItemProperty -Path IIS:\AppPools\DefaultAppPool -Name recycling.periodicRestart.schedule -Value @{value = '03:00:00'}

And then try to get it, you will see the value.

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