This article is just a memo of some commands line that i use everyday to manage my virtuals environments. I hope will help you !
I will try to group the different commands lines by categories. These commands can be either PowerCLI or CLI.
STORAGE :
Set RDM LUNs to Perennially Reserved – Fixes slow boot of ESXi :
Via SSH
1 |
esxcli storage core device setconfig -d naa.6006016006912cxxxxxxxxxxxxx --perennially-reserved=true |
Via PowerCLI
Enable Round Robin path policy on all LUN :
CHECK NO RR : This command line check LUN’s are not configure with RR
1 |
Get-VMHost | Get-VMHostHba -Type "FibreChannel" |Get-ScsiLun -LunType "disk"|where {$_.MultipathPolicy -ne "RoundRobin"} |
SETUP RR : Enable RR on all hosts
1 |
Get-VMHost | Get-ScsiLun -LunType "disk"|where {$_.MultipathPolicy -ne "RoundRobin"}|Set-ScsiLun -MultipathPolicy RoundRobin |
SETUP RR : Enable RR on all hosts in a specific cluster
1 |
Get-Cluster -Name "NAMECLUSTER"| Get-VMHost | Get-ScsiLun -LunType "disk"|where {$_.MultipathPolicy -ne "RoundRobin"}|Set-ScsiLun -MultipathPolicy RoundRobin |
List all parameters of a LUN :
1 |
esxcli storage core device list -d naa.60060160cd7031xxxxxxxxxxxx |
Adding an NFS share to multiple hosts :
1 |
Get-VMHost | New-Datastore -Nfs -Name DATASTORENAME -Path "/volume/path" -NfsHost FQDN -ReadOnly |
Convert a disk to eagerzeroedthick while keeping the data :
1 |
vmkfstools -k "My VM.vmdk" |
Add dynamic discovery iSCSI Target :
1 |
Get-VMHost -name "FQDN" | Get-VMHostHba -Type iSCSI | New-IScsiHbaTarget -Address "IPTARGET" |
Rescan all HBA :
1 |
Get-VMHost | Get-VMHostStorage -RescanAllHba |
NETWORK :
Add a VLAN to all nodes in a cluster :
1 |
Get-Cluster "NAMECLUSTER" | Get-VMHost | Get-VirtualSwitch -name vSwitch1 | New-VirtualPortGroup -name "VLAN70" -VLanId 70 |
Delete a VLAN on all nodes in a cluster :
1 |
Get-Cluster "NAMECLUSTER" | Get-VMHost | Get-VirtualPortGroup -Name "VLAN849" | Remove-VirtualPortGroup |
OTHERS :
List all PoweredOff VM with disk space and export to CSV :
1 |
Get-Vm | where { $_.PowerState -eq "PoweredOff"} | Select-Object @{e={$_.name};n="Name"},@{e={$_.ProvisionedSpaceGB};n="ProvisionedSpaceGB"},@{e={$_.VMHost};n="VMHost"} | Export-csv -Path c:\temp\export.csv -Encoding utf8 |
Check Logs live ESX
1 |
tail -f /var/log/vmkernel.log |
If you have any questions don’t hesitate to post a comment, or to contact me
Hi ! I’m Maxime. Founder and independant author of vDays.net. I have worked in service IT since 6 years ago, after a 5 years’ internship. Via this blog, I would like share and discuss with you on new technologies, especially on virtualization and VMware. If you want to know more about me, check out my “about me” page or follow me on Twitter and LinkedIn