I'm trying to automate some web application deployment tasks so I'm attempting to use powershell to accomplish this. I have a powershell script and a .bat file. The batch file is just there to execute the powershell script and contains this text. I'm on Windows 8 - 64bit.
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\SetupWebServer.ps1' %*
I have some code in the powershell script that runs these commands:
Write-Host "Check for the existence of the Application Pool."
Import-Module WebAdministration
$iisAppPoolName = "SiteName"
$iisAppPoolDotNetVersion = "v4.0"
$iisAppName = "SiteName"
cd IIS:\AppPools\
if (!(Test-Path $iisAppPoolName -PathType Container))
{
Write-Host "Creating Application Pool"
}
When I get to the CD IIS:\AppPools\ command I get the following error:
cd : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the
following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At line:1 char:1
+ cd IIS:\AppPools\
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Location], COMException
+ FullyQualifiedErrorId :
System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.SetLocationCommand
From a separate powershell prompt, I can cd to IIS:\, but I can't run the dir command and get a similar error. What am I missing?
By specifying SysWOW64
you are forcing Powershell to run in a 32bit context. The WebAdministration module only supports a 64bit context.
Solution:
SysNative
instead of SysWOW64
SysWOW64
and use the standard path.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With