【发布时间】:2012-01-10 21:08:31
【问题描述】:
我正在创建一个函数来将 IIS7 中的应用程序池管理为我们所需的规范,但我在转换等效 IIS6 脚本中的一行时遇到了问题;设置重启计划。
在 IIS6 中,该行是:
$newPool.PeriodicRestartSchedule = @( '6:15' );
IIS7 的天真翻译是:
$newPool.Recycling.PeriodicRestart.Schedule = @('00000000061500.000000:000')
但是这不起作用,因为它会引发异常:
Exception setting "Schedule": "Unable to cast object of type 'System.String'
to type 'System.Management.ManagementBaseObject'.
如何创建这个ScheduleElement[] 数组来分配给这个值?
编辑:问题 1 失败...:
$time = ([wmiclass]'root\WebAdministration:ScheduleElement').CreateInstance()
$time.Value = '00000000061500.000000:000'
$newPool.Recycling.PeriodicRestart.Schedule = $time;
问题 2:当我调用 $newPool.Put() 时,这个值似乎没有保存。下一步是什么?
【问题讨论】: