UUID
Get-VM VM_Name | %{(Get-View $_.Id).config.uuid}
MoRef ID
Get-VM VM_name | Get-View
Get-VM VM_name | Select Name, ID
Advertisements
UUID
Get-VM VM_Name | %{(Get-View $_.Id).config.uuid}
MoRef ID
Get-VM VM_name | Get-View
Get-VM VM_name | Select Name, ID
If you are going to add multiple hosts to vCenter and license them, it will take a while if you do it manually. Instead you can PowerCLI script it.
Open vSphere PowerCLI console and connect to the vCenter.
Connect-VIServer -Server $vCenterServerName
Next run the following commands for each host which add them to vCenter and then license them.
Add-VMHost $hostname -location $cluster -user root -password $root_password -force:$true Set-VMHost -VMHost $hostname -LicenseKey $license_key
I have a task to deploy 6 Appliance VMs from the same OVF template. I can deploy them manually one after the other which is a lot of labour and time. Instead, I can deploy one and clone it to create the rest. This is how to clone VM using PowerCLI:
Connect-VIServer -server $vCenter
New-VM -Name $NewVMName -VM $SourceVM -VMHost $TargetESXiHost -Datastore $TargetDatastore -RunAsync
New-NetworkAdapter -vm VMNAME -NetworkName PortGroupName -StartConnected
Copy the list of VMs to a file C:\vmlist.txt.
$vmlist = Get-Content C:\vmlist.txt foreach ($i in $vmlist) { Get-VM -Name $i | New-VIPermission -Role "ROLE_NAME" -Principal "Domain\GROUP" OR Get-VM -Name $i | New-VIPermission -Role "ROLE_NAME" -Principal "Domain\USER" }
To verify
$vmlist = Get-Content C:\vmlist.txt foreach ($i in $vmlist) { Get-VM -Name $i | Get-VIPermission | Where-Object {$_.Role -like "ROLE_NAME*"} }