Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell应用程序池集periodicRestart语法_Powershell_Iis_Application Pool - Fatal编程技术网

Powershell应用程序池集periodicRestart语法

Powershell应用程序池集periodicRestart语法,powershell,iis,application-pool,Powershell,Iis,Application Pool,我尝试使用powershell脚本设置属性,但我尝试使用的语法与我在代码示例中看到的略有不同 这里有一种方法可以根据: 但是,我已经有一个代码块,我正在对$appPool本身设置如下属性: $appPool = New-WebAppPool $iisAppPoolName $appPool.managedPipelineMode = "Classic" $appPool.managedRuntimeVersion = "c4.0" $appPool.recycling.periodicRest

我尝试使用powershell脚本设置属性,但我尝试使用的语法与我在代码示例中看到的略有不同

这里有一种方法可以根据:

但是,我已经有一个代码块,我正在对
$appPool
本身设置如下属性:

$appPool = New-WebAppPool $iisAppPoolName 
$appPool.managedPipelineMode = "Classic"
$appPool.managedRuntimeVersion = "c4.0"
$appPool.recycling.periodicRestart.time = [TimeSpan]"00:00:00"
$appPool | Set-Item
这很好,所以我想添加以下行:

$appPool.recycling.periodicRestart.schedule = @{value="01:00:00"}
但是我无法获取要采用的
@{value=“01:00:00”}
的语法。
schedule
属性需要一个哈希表,我正在传递它


有什么想法吗?

有趣的是,您将其视为一个
[Hashtable]
。我将其视为一个
[Microsoft.Iis.Powershell.Framework.ConfigurationElement]

它有一个名为
.UpdateCollection()
的方法,该方法需要一个
[PSObject[]]
,因此它要查找一个对象数组

问题是,无论是对从
newwebapppool
返回的池对象还是从
Get Item IIS:\AppPools\ExistingPool
返回的池对象调用该方法,都会导致一个错误,表明它是只读的

我尝试用添加了timespan对象的新arraylist替换整个
.Collection
,没有出现错误,但它没有设置值

我还尝试创建ConfigurationElement对象,但它似乎没有构造函数,因此它可能是代码中某个地方的私有类

我并不是说绝对没有办法按照您的意愿进行操作,但似乎您最好只使用
Set ItemProperty
,因为这些属性中的某些属性似乎只设计为通过PS提供商进行更新

$appPool.recycling.periodicRestart.schedule = @{value="01:00:00"}