The PSDrive IIS: is not recognised as a valid path in my serverspec test.
This is an example of a failing test:
describe command("Get-ItemProperty -Path IIS:\\AppPools\\#{webenv}#{net2_classic_32bit_apppoolpostfix} -Name enable32BitAppOnWin64 | foreach { $_.value}") do
its(:stdout) {should include "True"}
end
I have added Import-Module WebAdministration
to the base PowerShell profile on the server, but the IIS: PSDrive is still not recognised as a valid path in command resources. I get the following error:
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)>'
I saw mention of an add_pre_command method in the PowerShell command resource but I am not clear if this is what I need or how to run it?
I am open to suggestions to resolve this - can I force the PowerShell process serverspec is using to load the WebAdministration
profile? Or is there some other method?