15得票4回答
为什么PowerShell类方法中无法使用Write-Output?

我试图在PowerShell类方法中使用Write-Output输出变量,但它没有起作用。Write-Host可以工作。请参见下面的示例代码。class sample { [string] sampleMethod() { $output = "Output message" ...

11得票2回答
无法将“-persist”添加到New-PSDrive - 出现错误“网络资源类型不正确”

正如标题所述,如果我尝试将 -persist 添加到 cmdlet 中,它会返回以下错误: New-PSDrive:网络资源类型不正确 位于第 1 行,字符 1 处 + New-PSDrive -Name P -Root <redacted> ... + ~~~~~~~~~~~~...

10得票4回答
无法使用install-module安装几乎任何模块的Powershell

我的Powershell v5.1使用install-module命令无法自动安装几乎任何模块,但手动安装却可以正常工作。 首先,当我运行install-module命令时,它会下载模块,然后抛出错误,比如说pscX模块: PackageManagement\Install-Package...

8得票4回答
PowerShell更新帮助失败。

我刚开始从Microsoft虚拟学院学习PowerShell,我正在运行其中一个指示的命令。在他们那边可以工作,但我的却不行。我已经寻找解决此问题的方法。我只是不知道出了什么问题。对于这个新的PowerShell学习者,任何提示都将有帮助。 PS C:\Windows\system32&gt...

7得票1回答
Write-Information在通过Start-Transcript转录的文件中不显示。

我正在使用PowerShell 5.1,试图确定为什么Write-Information消息不会显示在由Start-Transcript创建的传输日志中,除非我将$InformationPreference设置为SilentlyContinue。我想要在控制台中同时显示这些消息,并将它们写入日...

7得票1回答
Powershell强制重新加载以使用模块

有没有一种方法可以强制PowerShell在使用“using module .\MyModule.psm1”时重新加载模块? 通常,我会使用“Import-Module .\MyModule.psm1 -Force”,但由于我正在使用C#风格的“enum”和“class”,这样做不起作用;因...