VMWare PowerCLI and my use
- Jason Kline
- Apr 28, 2021
- 1 min read
I use this blog to share and for my own documentation and referencing back items I forget. I find this interesting and useful in VMWare environments, I hop this helps you, it did me.
Command (missing some per-requisites). In case you run into this issue you may need to install. NuGet. Internet access is a requirement.
Step 1. Install VMWare Power CLI
Open Powershell as an Administrator and run the follwing
Install-Module -Name VMware.PowerCLI
If your receive an error you may need to install NuGet, these are the commands I used to install and then try installing VMware.PowerCLI. If installing NuGet fails you may need to install manually.
Automatic:
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Manual:
$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = "$rootPath\nuget.exe"
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Retry:
Install-Module -Name VMware.PowerCLI
Answer yes or all to installing supporting modules
Connect to your vCenter or ESXi host, enter your creds when asked
Connect-VIServer -Server <your hostname or IP> -Protocol https
Disable cert validation on your host or VC:
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
Run your commands, this was the few I used, try them in your lab or VM environment.
Get-VM | Select-Object Name,Notes,VMHost,Guest
Get-VM | Select-Object Name,Notes,VMHost,Guest | findstr <your VM name>
I was looking for a specific MAC: (Example MAC)
Get-VM | Get-NetworkAdapter | Where {$_.MacAddress -eq “AB:CD:EF:01:02:03”} | Select-Object Parent,Name,MacAddress
Get-Command -Module VMware.PowerCLI
Commands: (use Get-Help in front of commands for more information)
Connect-VIServer
Get-VICommand
Get-PowerCLIHelp
Get-VM
Get-PowerCLICommunity
Comments