3
如下图所示
简单的脚本导致我的电脑上的异常:的PowerShell:命令 “GET-ChildItem IIS:网站” 将导致错误
Import-Module WebAdministration
Get-ChildItem IIS:\Sites
结果:
powershell -NonInteractive .\test.ps1
Get-ChildItem : Could not load file or assembly 'Microsoft.PowerShell.Commands.Management' or one of its dependencies. The system cannot
find the file specified.
At C:\...\test.ps1:3 char:1
+ Get-ChildItem IIS:\Sites
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-ChildItem], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.GetChildItemCommand
但是,如果我加写在脚本的开始-Host正常工作:
Write-Host '!!!'
Import-Module WebAdministration
Get-ChildItem IIS:\Sites
不幸的是,我不知道什么可能导致此问题。有人能帮助我吗?
幸运的是在PowerShell 2.0中工作正常:)它可以在3.0中的错误 – RinoTom 2013-02-14 18:59:23