日期:2023-04-18  浏览次数:479 次

如果您无法在 Visual Studio 2017 或更高版本的安装程序中找到“Windows PowerShell”工作负载选项,则可能是因为您选择的安装选项中不包含该工作负载。

在这种情况下,您可以通过以下步骤手动安装 PowerShell SDK:

  1. 下载 PowerShell SDK 安装程序,下载地址为:http://github.com/PowerShell/PowerShell/releases/tag/v7.2.0。
  2. 运行 PowerShell SDK 安装程序。
  3. 在安装程序中选择“Custom”(自定义)选项。
  4. 选择“SDK”选项,然后单击“Install”(安装)。

完成安装后,您可以手动添加 System.Management.Automation 程序集的引用。在 Visual Studio 中手动添加 System.Management.Automation 程序集的引用的步骤已经在前面的回答中进行了说明。