4
我試圖自動化一些Web應用程序部署任務,所以我試圖使用PowerShell來實現此目的。 。PowerShell腳本和.bat文件的批處理文件就在那裏執行PowerShell腳本,幷包含這段文字,我在Windows 8 - 。64無法在IIS中運行'dir'或'Get-ChildItem'命令: powershell
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\SetupWebServer.ps1' %*
我有一些代碼在運行PowerShell腳本這些命令:
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"
}
當我到CD IIS:\ AppPools \命令時出現以下錯誤:
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
從一個單獨的powershell提示符,我可以cd到IIS:\,但我不能運行dir命令並得到類似的錯誤。我錯過了什麼?
已將批處理文件中的路徑更改爲「%windir%\ Sysnative \ WindowsPowerShell \ v1.0 \ powershell.exe」,而且似乎可行。 – sdanna