【发布时间】:2013-02-13 20:50:00
【问题描述】:
下面显示的简单脚本导致我的计算机出现异常:
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
但是,如果我在脚本开头添加 Write-Host,它就可以正常工作:
Write-Host '!!!'
Import-Module WebAdministration
Get-ChildItem IIS:\Sites
很遗憾,我不知道是什么原因导致了这个问题。有人可以帮我吗?
【问题讨论】:
-
幸运的是它在 PowerShell 2.0 中运行良好 :) 它可能是 3.0 中的一个错误
标签: powershell powershell-3.0 web-administration