借鑑自 https://blogs.vmware.com/PowerCLI/2017/04/powercli-install-process-powershell-gallery.html
下載Vmware powercli的 powershell modules
https://code.vmware.com/web/tool/12.1.0/vmware-powercli
powershell鍵入$ENV:PSModulePath來確認當前電腦的powershell環境變量。
PS C:\Users\wuym> $ENV:PSModulePath
C:\Users\wuym\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\Windows
PowerShell\v1.0\Modules;C:\Program Files\Citrix\Telemetry Service\
1 Local User: $home\Documents\WindowsPowerShell\Modules
2 All Users: $pshome\Modules
把下載的powercli modules解壓到 C:\Program Files\WindowsPowerShell\Modules路徑下
使用 PowerCLI
首先,我們來導入Modules到powershell中:
Import-Module VMware.PowerCLI
創建桌面快捷方式
我知道有相當多的桌面快捷方式的粉絲,所以將簡要地描述如何設置它。首先,創建指向 PowerShell 可執行文件的快捷方式,並放在桌面上。接下來,右鍵單擊新創建的桌面快捷方式並選擇屬性。您應該發現自己在"快捷方式"選項卡上。輸入以下值:
1 Target: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c "Import-Module VMware.PowerCLI"
2 Start In: C:\
3 Shortcut Key: None
4 Run: Normal Window
5 Comment: Launch VMware PowerCLI
最後,我們應該有類似下面的東西: