powershell - 如何使用 PowerShell 在 IIS 中设置 rapidFailProtectionInterval?

标签 powershell iis application-pool

我正在尝试在 MS WSUS 设置上配置 WsusPool 的应用程序池,以使用 PowerShell 作为管理员将故障快速故障保护间隔从 5 分钟提高到 30 分钟。

我可以使用获取设置

Install-WindowsFeature Web-Mgmt-Console

Import-Module WebAdministration

$WsusPool = Get-Item IIS:\AppPools\WsusPool\
$WsusPool.failure.rapidFailProtectionInterval

Days              : 0
Hours             : 0
Minutes           : 5
Seconds           : 0
Milliseconds      : 0
Ticks             : 3000000000
TotalDays         : 0.00347222222222222
TotalHours        : 0.0833333333333333
TotalMinutes      : 5
TotalSeconds      : 300
TotalMilliseconds : 300000

但是当我尝试保存对值的更改时出现错误

$WsusPool.failure.rapidFailProtectionInterval = New-TimeSpan -Minutes 30
$WsusPool | Set-Item

Set-Item : Specified cast is not valid.
At line:1 char:13
+ $WsusPool | Set-Item
+             ~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Item], InvalidCastException
    + FullyQualifiedErrorId : path,Microsoft.PowerShell.Commands.SetItemCommand

系统的一些数据:

Version of PowerShell:

PS C:\Windows\system32> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  1490

Operating system:

PS C:\Windows\system32> Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, ServicePackMajorVersion, OSArchitecture, WindowsDirectory


Caption                 : Microsoft Windows Server 2019 Standard
Version                 : 10.0.17763
ServicePackMajorVersion : 0
OSArchitecture          : 64-bit
WindowsDirectory        : C:\Windows

最佳答案

您可以像这样使用Set-WebConfigurationProperty

Set-WebConfigurationProperty '//*[@name="WsusPool"]//failure' -Name rapidFailProtectionInterval -Value (New-TimeSpan -Minutes 30)

Here是关于该主题的非常有帮助的页面

关于powershell - 如何使用 PowerShell 在 IIS 中设置 rapidFailProtectionInterval?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64722098/

相关文章:

iis-7 - 使用 MSDeploy 为包设置应用程序池

powershell - IIS 7.5 应用程序池/IIS 管理器 GUI 列 : Applications

windows - 在 powershell 中检查时区的语言独立方式?

postgresql - 将 AD 属性添加到 SQL 查询输出

asp.net - 我可以在 IIS 5 中自动创建 .NET Web 应用程序/虚拟目录吗?

c# - 如何在本地 IIS 而非 Express 中调试 ASP.NET 5 Web 应用程序

c# - 带有 IIS 的 C# 中的 ServerManagerDemoGlobals 类在哪里

function - 按下取消按钮时读取主机返回的值

powershell - Office365 - 如何在 powershell 中使用 ImmutableId 检索 UPN?

asp.net - IIS 中关于 session 超时的查询