1. 查看当前素有的版本
PS /root> Find-Module -Repository PSGallery -Name VMware.PowerCLI -AllVersions | ft -AutoSize
Version Name Repository Description
------- ---- ---------- -----------
12.3.0.17860403 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
12.2.0.17538434 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
12.1.0.17009493 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
12.0.0.15947286 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
11.5.0.14912921 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
11.4.0.14413515 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
11.3.0.13990089 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
11.2.0.12780525 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
11.2.0.12483598 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
11.1.0.11289667 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
11.0.0.10380590 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
10.2.0.9372002 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
10.1.1.8827524 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
10.1.0.8403314 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
10.0.0.7895300 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
6.5.4.7155375 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
6.5.3.6870460 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
6.5.2.6268016 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
6.5.1.5377412 VMware.PowerCLI PSGallery This Windows PowerShell module contains VMware.PowerCLI
2. 创建脚本目录
mkdir /opt/PowerCLIModules
3. 安装
- 在线安装
PS /root> Save-Module -Name VMware.PowerCLI -RequiredVersion 12.1.0.17009493 -Path /opt/powercli
- 离线安装
下载地址 https://code.vmware.com/doc/preview?id=13693
4. 查看环境变量路径
PS /root> $env:PSModulePath
/root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
5. 解压安装包到/opt/microsoft/powershell/7/Modules
6. 验证是否安装成功
PS /root> Get-Module -Name VMware.PowerCLI -ListAvailable
Directory: /opt/microsoft/powershell/7/Modules/PowerCLIModules
ModuleType Version PreRelease Name PSEdition ExportedCommands
---------- ------- ---------- ---- --------- ----------------
Manifest 12.1.0.17… VMware.PowerCLI Desk
7. 忽略SSL证书
- 错误提示
PS /root> Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCeip $false -confirm:$false
Scope ProxyPolicy DefaultVIServerMode InvalidCertificateAction DisplayDeprecationWarnings WebOperationTimeout
Seconds
----- ----------- ------------------- ------------------------ -------------------------- -------------------
Session UseSystemProxy Multiple Unset True 300
User
AllUsers
PS /root> Set-PowerCLIConfiguration -Scope AllUsers -InvalidCertificateAction Ignore -confirm:$false
Scope ProxyPolicy DefaultVIServerMode InvalidCertificateAction DisplayDeprecationWarnings WebOperationTimeout
Seconds
----- ----------- ------------------- ------------------------ -------------------------- -------------------
Session UseSystemProxy Multiple Ignore True 300
User
AllUsers Ignore
END