如何通过 PowerShell 脚本本身在多台机器上安装 PowerShell 模块
How to install a PowerShell module on multiple machines via PowerShell script itself
我需要在我环境中的各种机器上安装 Bitlocker 相关模块。我无法手动一一安装。我需要自动安装。有人可以指出我正确的方向并为我提供指导。
我找不到关于此的任何以前的问题。我看到下面的问题,但我们并没有在所有机器上安装 NuGet。
Use nuget to install PowerShell modules at user machine
您可以为此利用 PowerShell Gallery 功能。
先决条件:确保您拥有 PowerShellGet 模块。此模块随 Windows 管理框架 (WMF) 5.0 一起提供,或者您可以使用基于 MSI 的安装程序并将其包含在 PowerShell 3 和 4 中。如果尚不存在,您可以通过 SCCM 推送它。
所需的 Cmdlet: 使用以下 cmdlet 执行所需的操作。您可以在脚本中使用这些 cmdlet 并 运行 针对您环境中的多台计算机。
#Check if module exists using Find-Module cmdlet
Find-Module xBitlocker
#Install the module using the Install-Module cmdlet
Install-Module -Name xBitlocker -Force
#Check module is on current machine already using below cmdlet
Get-Module -Name xBitlocker
#Save the module on local machine without installing
Save-Module -Name xBitlocker -Path <path here>
#Install the module using the below cmdlet
Uninstall-Module -Name xBitlocker -Force
您可以使用这些 cmdlet 并针对多台计算机创建脚本 运行。
您也可以将 xBitlocker
更改为另一个模块名称。
我需要在我环境中的各种机器上安装 Bitlocker 相关模块。我无法手动一一安装。我需要自动安装。有人可以指出我正确的方向并为我提供指导。
我找不到关于此的任何以前的问题。我看到下面的问题,但我们并没有在所有机器上安装 NuGet。 Use nuget to install PowerShell modules at user machine
您可以为此利用 PowerShell Gallery 功能。
先决条件:确保您拥有 PowerShellGet 模块。此模块随 Windows 管理框架 (WMF) 5.0 一起提供,或者您可以使用基于 MSI 的安装程序并将其包含在 PowerShell 3 和 4 中。如果尚不存在,您可以通过 SCCM 推送它。
所需的 Cmdlet: 使用以下 cmdlet 执行所需的操作。您可以在脚本中使用这些 cmdlet 并 运行 针对您环境中的多台计算机。
#Check if module exists using Find-Module cmdlet
Find-Module xBitlocker
#Install the module using the Install-Module cmdlet
Install-Module -Name xBitlocker -Force
#Check module is on current machine already using below cmdlet
Get-Module -Name xBitlocker
#Save the module on local machine without installing
Save-Module -Name xBitlocker -Path <path here>
#Install the module using the below cmdlet
Uninstall-Module -Name xBitlocker -Force
您可以使用这些 cmdlet 并针对多台计算机创建脚本 运行。
您也可以将 xBitlocker
更改为另一个模块名称。