如何安裝 PowerShell 模組特定版本?
要安裝 PowerShell 模組的特定版本,我們需要使用包含 -RequiredVersion 引數的 Install-Module 命令。
要查詢有哪些模組版本可用,我們可以使用包含 -AllVersions 引數的 Find-Module 命令,它將檢索 PSGallery 中所有可用的模組版本。
在本例中,我們將使用 7Zip4PowerShell 模組。
示例
Find-Module 7zip4PowerShell -AllVersions | ft -AutoSize
執行此命令時,你可以看到這個模組有很多可用的版本。
輸出
Version Name Repository ------- ---- ---------- 1.13.0 7Zip4Powershell PSGallery 1.12.0 7Zip4Powershell PSGallery 1.11.0 7Zip4Powershell PSGallery 1.10.0.0 7Zip4Powershell PSGallery 1.9.0 7Zip4Powershell PSGallery 1.8.0 7Zip4Powershell PSGallery 1.7.1 7Zip4Powershell PSGallery
我們需要在此處為所有使用者安裝 1.9.0 版本,因此我們將使用以下命令。
示例
Install-Module 7Zip4PowerShell -RequiredVersion 1.8.0 -Scope AllUsers -Force -Verbose
要在遠端伺服器上安裝 PowerShell 模組,請使用以下命令,
語法
Invoke-Command -ComputerName RemoteMachine1 -ScriptBlock {Install-Module 7Zip4PowerShell -RequiredVersion 1.8.0 -Scope AllUsers -Force -Verbose}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP