我的机器上有两个不同版本的Powershell。
使用powershell.exe我可以执行
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$oReturn=[System.Windows.Forms.Messagebox]::Show("This is the Message text")
但是用pwsh.exe我得到了错误
Exception calling "LoadWithPartialName" with "1" argument(s): "Could not load file or assembly 'System.Windows.Forms, Culture=neutral, PublicKeyToken=null'. Operation is not supported. (Exception from HRESULT: 0x80131515)"
At line:1 char:2
+ [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Fo ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException
这是怎么回事?在过去的六个月中,每次打开powershell时,我都会遭到垃圾邮件攻击,并被告知要升级到powershell6。现在我可以了,以上都不起作用。