Most of the time, I use vCenter (Web) Client for day to day operation, for a massive deployment, I have played a bit with PowerCLI. As it is a complete framework, some gems that really helped me.
You should already be logged in vCenter
Set ESXi powermanagement on “Maximum performance”
$hostname="fqdn" $view = (Get-VMHost $hostname| Get-View) (Get-View $view.ConfigManager.PowerSystem).ConfigurePowerPolicy(1)
Configure multiple IP addresses from DHCP to Fixed IP
You need a CSV file with
srvname,ipmgmt,ipvmotion
as header inside the file
$servers = "$($ScriptPath)servers.txt" $FileInitExists = Test-Path $servers if ($FileInitExists -eq $false){ "servers.txt does not exist. Create it and place the aliases, one per line" exit } $file = Import-Csv $servers foreach ($row in $file){ $name="$($row.srvname).esx.mercuria.met" write-host "$name $($row.ipmgmt) $($row.ipvmotion)" $srv=get-vmhost -Name $name Get-VMHost $srv| Get-VMHostNetworkAdapter -VMKernel -Name vmk0 |Set-VMHostNetworkAdapter -IP $($row.ipmgmt) -SubnetMask 255.255.255.0 -Confirm:$false Get-VMHost $srv| Get-VMHostNetworkAdapter -VMKernel -Name vmk1 |Set-VMHostNetworkAdapter -IP $($row.ipvmotion) -SubnetMask 255.255.255.0 -Confirm:$false }
NB default gateway is another set of commands, normally the same value as DHCP
Configure all LUN for a disk array to round robin multipath
$srv=get-vmhost -Name $name Get-ScsiLun -CanonicalName "naa.60030d90*" -VmHost $srv| Set-ScsiLun -MultipathPolicy "roundrobin"
Bypass Powerpath for Hitachi disk array
$srv=get-vmhost -Name $name $cli=Get-EsxCli -vmhost $srv $cli.storage.core.claimrule.remove($null,$null,"280") $cli.storage.core.claimrule.add($null,$null,$null,$null,$null,$null,$null,$null,$null,$null,"*","NMP",201,$null,$null,"vendor","HITACHI",$null,$null)
Rescan all HBAs
$srv=get-vmhost -Name $name Get-VMHostStorage -VmHost $srv-RescanAllHba
Useful in a foreach loop 😉
Disable all VAAI
$srv=get-vmhost -Name "fqdn" Set-VMHostAdvancedConfiguration -VMHost $srv -Name DataMover.HardwareAcceleratedMove -Value 0 Set-VMHostAdvancedConfiguration -VMHost $srv -Name DataMover.HardwareAcceleratedInit -Value 0 Set-VMHostAdvancedConfiguration -VMHost $srv -Name VMFS3.HardwareAcceleratedLocking -Value 0
Set 1 to re-enable
Set host in maintenance mode
Set-VMHost -VMHost $srv -state Maintenance -RunAsync -Confirm:$false
To exit :
Set-VMHost -VMHost $srv -state Connected -RunAsync -Confirm:$false
Working with annotations
$myvalue=get-vm $vm | Get-Annotation -CustomAttribute "my-annotation"
Reboot an ESX
Remember that maintenance mode is normally a best practive
Restart-VMHost $srv -RunAsync -force -Confirm:$false
Disable IPv6 in vSphere 5.5
$cli = Get-EsxCli -vmhost $srv $cli.network.ip.set($false)
Attach a host profile
Set-VMHost -VMHost $ucs -profile "UCS-RDM-55"