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