Install PowerCLI
Ⅰ在線安裝
在線安裝可以直接從 PowerShell Gallery安裝
Install-Module -Name VMware.PowerCLI
Ⅱ離線安裝
-
下載PowerCLI Module.zip文件 from here
-
檢查PowerShell模塊路徑,執行以下命令
$env:PSModulePath
-
將下載的.zip文件解壓縮到PowerShell模塊路徑
-
解鎖文件
cd path_to_powershell_modules_folder
Get-ChildItem * -Recurse | Unblock-File
- 執行以下命令以驗證PowerCLI模塊是否可用
Get-Module -Name VMware.PowerCLI -ListAvailable
預操作:以下兩條執行一次以后就不用了。
-
關閉CEIP( Customer Experience Improvement Program 客戶體驗改進計划)
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
-
忽略證書驗證
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore
打開PowerShell導入模塊
Import-Module VMware.PowerCLI
將PowerCLI加載到PowerShell ISE中
適用於PowerCLI 6.x安裝版本
#查看當前profile文件目錄
PS C:\Users\Administrator> Write-Host $profile
C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
#創建profile文件
PS C:\Users\Administrator> New-Item -ItemType file $profile -force
目錄: C:\Users\Administrator\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2021/4/8 12:45 0 Microsoft.PowerShellISE_profile.ps1
- 將
Initialize-PowerCLIEnvironment.ps1
中的內容粘貼到剛創建的profile文件中 - powercli啟動文件路徑
C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts
PowerCLI6.x安裝版的會有這個,我使用的12.x並沒有這個目錄和文件
如果有哪位知道怎么在PowerShell ISE中啟動加載PowerCLI 12.x的可以留言告知
參考&引用:
- 安裝PowerCLI
- VMware PowerCLI 12.2.0用戶手冊
- https://blogs.vmware.com/PowerCLI/2017/04/powercli-install-process-powershell-gallery.html
- https://code.vmware.com/docs/7053/cmdlet-reference
©轉載請注明出處