1

PSDrive IIS: 在我的 serverspec 测试中未被识别为有效路径。

这是一个失败的测试示例:

describe command("Get-ItemProperty -Path IIS:\\AppPools\\#{webenv}#{net2_classic_32bit_apppoolpostfix} -Name enable32BitAppOnWin64 | foreach { $_.value}") do
 its(:stdout) {should include "True"}
end

我已添加Import-Module WebAdministration到服务器上的基本 PowerShell 配置文件,但 IIS: PSDrive 仍然未被识别为命令资源中的有效路径。我收到以下错误:

Command "Get-ItemProperty -Path IIS:\AppPools\t01_systesticelegacywsx32 -Name enable32BitAppOnWin64 | foreach { $_.value}" stdout should include "True"
    On host `localhost'
    Failure/Error: its(:stdout) {should include "True"}
      expected "" to include "True"
      Get-ItemProperty -Path IIS:\AppPools\t01_systesticelegacywsx32 -Name enable32BitAppOnWin64 | foreach { $_.value}
      #< CLIXML
Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS
<I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><S S="Error">Get-ItemPrope
ty : Cannot find drive. A drive with the name 'IIS' does not exist._x000D__x000A_</S><S S="Error">At line:1 char:1_x000D__x000A_</S><S S="Error">+ Get-ItemProperty -Path IIS:\AppPools\t01_systesticel
gacywsx32 -Name  ..._x000D__x000A_</S><S S="Error">+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound:
IIS:String) [Get-ItemProperty], DriveNotFoundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand_x000D__x000A_</S>
S S="Error"> _x000D__x000A_</S></Objs>
    # ./spec/localhost/add_legacyicews_spec.rb:87:in `block (4 levels) in <top (required)>'

我在 PowerShell 命令资源中看到提到了 add_pre_command 方法,但我不清楚这是我需要的还是如何运行它?

我愿意接受解决此问题的建议 - 我可以强制使用 PowerShell 进程 serverspec 来加载WebAdministration配置文件吗?还是有其他方法?

4

0 回答 0