我写了一个脚本来显示一个消息框。它在 PowerShell 5 中运行良好,但在 PowerShell 6 中不运行。我怎样才能使它工作?
我写的脚本(摘录):
function test
{
[CmdletBinding()]
param([Parameter(Mandatory = $true, Position = 0)][string]$directory)
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName Microsoft.Visualbasic
Add-Type -AssemblyName System.Drawing
#----------------------------
}
错误信息:
添加类型:找不到路径“C:\Users\Owner\System.Windows.Forms.dll”,因为它不存在。在 C:\Users\Owner\Desktop\sample\trans-search.ps1:8 char:6 + Add-Type -AssemblyName System.Windows.Forms + ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\Users\Owner\System.Windows.Forms.dll:String) [添加类型],ItemNotFoundException + FullyQualifiedErrorId:PathNotFound,Microsoft.PowerShell.Commands.AddTypeCommand
谢谢您的帮助。