Friday, October 23, 2015

PowerCLI script to move VMs from the Root Resource pool to a Specific Resource Pool

While troubleshooting an performance issue on a VM today, I noticed a misconfiguration in the resource pool settings. In this specific cluster, there was a bunch of VMs in the root of the resource pool, hence, skewing the resources to be granted when there is contention.

Here's a one liner PowerCLI code to move all the VMs in the root of the cluster to a specific resource pool:


Get-Cluster "Cluster-Name" | Get-VM | where {$_.ResourcePool.Name -eq "Resources"} | Move-VM -Destination (Get-Cluster "Cluster-Name" | Get-ResourcePool "Resource-Pool-Name")

Thursday, October 15, 2015

List of ESXcli Commands

Below is a list of ESXcli commands and the required parameters for reference:


$esxcli.device
$esxcli.device.alias
$esxcli.device.alias.get(string alias)
$esxcli.device.alias.list()
$esxcli.esxcli
$esxcli.esxcli.command
$esxcli.esxcli.command.list()
$esxcli.fcoe
$esxcli.fcoe.adapter
$esxcli.fcoe.adapter.list()
$esxcli.fcoe.nic
$esxcli.fcoe.nic.disable(string nicname)
$esxcli.fcoe.nic.discover(string nicname)
$esxcli.fcoe.nic.list()
$esxcli.graphics
$esxcli.graphics.device
$esxcli.graphics.device.list()
$esxcli.graphics.vm
$esxcli.graphics.vm.list()
$esxcli.hardware
$esxcli.hardware.bootdevice
$esxcli.hardware.bootdevice.list()
$esxcli.hardware.clock
$esxcli.hardware.clock.get()
$esxcli.hardware.clock.set(long day, long hour, long min, long month, long sec, long year)
$esxcli.hardware.cpu
$esxcli.hardware.cpu.cpuid
$esxcli.hardware.cpu.cpuid.get(long cpu)
$esxcli.hardware.cpu.global
$esxcli.hardware.cpu.global.get()
$esxcli.hardware.cpu.global.set(boolean hyperthreading)
$esxcli.hardware.cpu.list()
$esxcli.hardware.ipmi
$esxcli.hardware.ipmi.fru
$esxcli.hardware.ipmi.fru.get(boolean ignoremissing, boolean includeraw, string node)
$esxcli.hardware.ipmi.fru.list(boolean ignoremissing, boolean includeraw, string node)
$esxcli.hardware.ipmi.sdr
$esxcli.hardware.ipmi.sdr.get(boolean ignoremissing, boolean includeraw, string node)
$esxcli.hardware.ipmi.sdr.list(boolean ignoremissing, boolean includeraw, string node)
$esxcli.hardware.ipmi.sel
$esxcli.hardware.ipmi.sel.get(boolean ignoremissing, boolean includeraw, string node)
$esxcli.hardware.ipmi.sel.list(boolean ignoremissing, boolean includeraw, string node)
$esxcli.hardware.ipmi.help()
$esxcli.hardware.memory
$esxcli.hardware.memory.get()
$esxcli.hardware.pci
$esxcli.hardware.pci.list(string class, string mask)
$esxcli.hardware.platform
$esxcli.hardware.platform.get()
$esxcli.hardware.trustedboot
$esxcli.hardware.trustedboot.get()
$esxcli.iscsi
$esxcli.iscsi.adapter
$esxcli.iscsi.adapter.auth
$esxcli.iscsi.adapter.auth.chap
$esxcli.iscsi.adapter.auth.chap.get(string adapter, string direction)
$esxcli.iscsi.adapter.auth.chap.set(string adapter, string authname, boolean default, string direction, string level, string secret)
$esxcli.iscsi.adapter.auth.help()
$esxcli.iscsi.adapter.capabilities
$esxcli.iscsi.adapter.capabilities.get(string adapter)
$esxcli.iscsi.adapter.discovery
$esxcli.iscsi.adapter.discovery.sendtarget
$esxcli.iscsi.adapter.discovery.sendtarget.auth
$esxcli.iscsi.adapter.discovery.sendtarget.auth.chap
$esxcli.iscsi.adapter.discovery.sendtarget.auth.chap.get(string adapter, string address, string direction)
$esxcli.iscsi.adapter.discovery.sendtarget.auth.chap.set(string adapter, string address, string authname, boolean default, string direction, boolean inherit, string level, string secret)
$esxcli.iscsi.adapter.discovery.sendtarget.auth.help()
$esxcli.iscsi.adapter.discovery.sendtarget.param
$esxcli.iscsi.adapter.discovery.sendtarget.param.get(string adapter, string address)
$esxcli.iscsi.adapter.discovery.sendtarget.param.set(string adapter, string address, boolean default, boolean inherit, string key, string value)
$esxcli.iscsi.adapter.discovery.sendtarget.add(string adapter, string address)
$esxcli.iscsi.adapter.discovery.sendtarget.list(string adapter)
$esxcli.iscsi.adapter.discovery.sendtarget.remove(string adapter, string address)
$esxcli.iscsi.adapter.discovery.statictarget
$esxcli.iscsi.adapter.discovery.statictarget.add(string adapter, string address, string name)
$esxcli.iscsi.adapter.discovery.statictarget.list(string adapter)
$esxcli.iscsi.adapter.discovery.statictarget.remove(string adapter, string address, string name)
$esxcli.iscsi.adapter.discovery.status
$esxcli.iscsi.adapter.discovery.status.get(string adapter)
$esxcli.iscsi.adapter.discovery.rediscover(string adapter)
$esxcli.iscsi.adapter.firmware
$esxcli.iscsi.adapter.firmware.get(string adapter, string file)
$esxcli.iscsi.adapter.firmware.set(string adapter, string file)
$esxcli.iscsi.adapter.param
$esxcli.iscsi.adapter.param.get(string adapter)
$esxcli.iscsi.adapter.param.set(string adapter, boolean default, string key, string value)
$esxcli.iscsi.adapter.target
$esxcli.iscsi.adapter.target.portal
$esxcli.iscsi.adapter.target.portal.auth
$esxcli.iscsi.adapter.target.portal.auth.chap
$esxcli.iscsi.adapter.target.portal.auth.chap.get(string adapter, string address, string direction, string method, string name)
$esxcli.iscsi.adapter.target.portal.auth.chap.set(string adapter, string address, string authname, boolean default, string direction, boolean inherit, string level, string name, string secret)
$esxcli.iscsi.adapter.target.portal.auth.help()
$esxcli.iscsi.adapter.target.portal.param
$esxcli.iscsi.adapter.target.portal.param.get(string adapter, string address, string name)
$esxcli.iscsi.adapter.target.portal.param.set(string adapter, string address, boolean default, boolean inherit, string key, string name, string value)
$esxcli.iscsi.adapter.target.portal.list(string adapter, string name)
$esxcli.iscsi.adapter.target.list(string adapter, string name)
$esxcli.iscsi.adapter.get(string adapter)
$esxcli.iscsi.adapter.list(string adapter)
$esxcli.iscsi.adapter.set(string adapter, string alias, string name)
$esxcli.iscsi.ibftboot
$esxcli.iscsi.ibftboot.get()
$esxcli.iscsi.ibftboot.import()
$esxcli.iscsi.logicalnetworkportal
$esxcli.iscsi.logicalnetworkportal.list(string adapter)
$esxcli.iscsi.networkportal
$esxcli.iscsi.networkportal.ipconfig
$esxcli.iscsi.networkportal.ipconfig.get(string adapter, string nic)
$esxcli.iscsi.networkportal.ipconfig.set(string adapter, string dns1, string dns2, string gateway, string ip, string nic, string subnet)
$esxcli.iscsi.networkportal.add(string adapter, boolean force, string nic)
$esxcli.iscsi.networkportal.list(string adapter)
$esxcli.iscsi.networkportal.remove(string adapter, boolean force, string nic)
$esxcli.iscsi.physicalnetworkportal
$esxcli.iscsi.physicalnetworkportal.param
$esxcli.iscsi.physicalnetworkportal.param.get(string adapter, string nic)
$esxcli.iscsi.physicalnetworkportal.param.set(string adapter, string nic, string option, long value)
$esxcli.iscsi.physicalnetworkportal.list(string adapter)
$esxcli.iscsi.plugin
$esxcli.iscsi.plugin.list(string adapter, string plugin)
$esxcli.iscsi.session
$esxcli.iscsi.session.connection
$esxcli.iscsi.session.connection.list(string adapter, string cid, string isid, string name)
$esxcli.iscsi.session.add(string adapter, string isid, string name)
$esxcli.iscsi.session.list(string adapter, string isid, string name)
$esxcli.iscsi.session.remove(string adapter, string isid, string name)
$esxcli.iscsi.software
$esxcli.iscsi.software.get()
$esxcli.iscsi.software.set(boolean enabled)
$esxcli.network
$esxcli.network.diag
$esxcli.network.diag.ping(long count, boolean debug, boolean df, string host, string interface, string interval, boolean ipv4, boolean ipv6, string netstack, string nexthop, long size, long ttl, string wait)
$esxcli.network.fence
$esxcli.network.fence.network
$esxcli.network.fence.network.bte
$esxcli.network.fence.network.bte.list(long fenceid, string vdsname)
$esxcli.network.fence.network.port
$esxcli.network.fence.network.port.list(long fenceid, string vdsname)
$esxcli.network.fence.network.list(long fenceid, string vdsname)
$esxcli.network.fence.list()
$esxcli.network.firewall
$esxcli.network.firewall.ruleset
$esxcli.network.firewall.ruleset.allowedip
$esxcli.network.firewall.ruleset.allowedip.add(string ipaddress, string rulesetid)
$esxcli.network.firewall.ruleset.allowedip.list(string rulesetid)
$esxcli.network.firewall.ruleset.allowedip.remove(string ipaddress, string rulesetid)
$esxcli.network.firewall.ruleset.rule
$esxcli.network.firewall.ruleset.rule.list(string rulesetid)
$esxcli.network.firewall.ruleset.list(string rulesetid)
$esxcli.network.firewall.ruleset.set(boolean allowedall, boolean enabled, string rulesetid)
$esxcli.network.firewall.get()
$esxcli.network.firewall.load()
$esxcli.network.firewall.refresh()
$esxcli.network.firewall.set(boolean defaultaction, boolean enabled)
$esxcli.network.firewall.unload()
$esxcli.network.ip
$esxcli.network.ip.connection
$esxcli.network.ip.connection.list(string netstack, string type)
$esxcli.network.ip.dns
$esxcli.network.ip.dns.search
$esxcli.network.ip.dns.search.add(string domain, string netstack)
$esxcli.network.ip.dns.search.list(string netstack)
$esxcli.network.ip.dns.search.remove(string domain, string netstack)
$esxcli.network.ip.dns.server
$esxcli.network.ip.dns.server.add(string netstack, string server)
$esxcli.network.ip.dns.server.list(string netstack)
$esxcli.network.ip.dns.server.remove(boolean all, string netstack, string server)
$esxcli.network.ip.dns.help()
$esxcli.network.ip.interface
$esxcli.network.ip.interface.ipv4
$esxcli.network.ip.interface.ipv4.get(string interfacename, string netstack)
$esxcli.network.ip.interface.ipv4.set(string interfacename, string ipv4, string netmask, boolean peerdns, string type)
$esxcli.network.ip.interface.ipv6
$esxcli.network.ip.interface.ipv6.address
$esxcli.network.ip.interface.ipv6.address.add(string interfacename, string ipv6)
$esxcli.network.ip.interface.ipv6.address.list()
$esxcli.network.ip.interface.ipv6.address.remove(string interfacename, string ipv6)
$esxcli.network.ip.interface.ipv6.get(string interfacename, string netstack)
$esxcli.network.ip.interface.ipv6.set(boolean enabledhcpv6, boolean enablerouteradv, string interfacename, boolean peerdns)
$esxcli.network.ip.interface.tag
$esxcli.network.ip.interface.tag.add(string interfacename, string tagname)
$esxcli.network.ip.interface.tag.get(string interfacename)
$esxcli.network.ip.interface.tag.remove(string interfacename, string tagname)
$esxcli.network.ip.interface.add(string dvportid, string dvsname, string interfacename, string macaddress, long mtu, string netstack, string portgroupname)
$esxcli.network.ip.interface.list(string netstack)
$esxcli.network.ip.interface.remove(string dvportid, string dvsname, string interfacename, string netstack, string portgroupname)
$esxcli.network.ip.interface.set(boolean enabled, string interfacename, long mtu)
$esxcli.network.ip.ipsec
$esxcli.network.ip.ipsec.sa
$esxcli.network.ip.ipsec.sa.add(string encryptionalgorithm, string encryptionkey, string integrityalgorithm, string integritykey, string sadestination, string samode, string saname, string sasource, string saspi)
$esxcli.network.ip.ipsec.sa.list()
$esxcli.network.ip.ipsec.sa.remove(boolean removeall, string sadestination, string saname, string sasource, string saspi)
$esxcli.network.ip.ipsec.sp
$esxcli.network.ip.ipsec.sp.add(string action, long destinationport, string flowdirection, string saname, long sourceport, string spdestination, string spmode, string spname, string spsource, string upperlayerprotocol)
$esxcli.network.ip.ipsec.sp.list()
$esxcli.network.ip.ipsec.sp.remove(boolean removeall, string spname)
$esxcli.network.ip.ipsec.set(string ikeconf)
$esxcli.network.ip.neighbor
$esxcli.network.ip.neighbor.list(string interfacename, string netstack, string version)
$esxcli.network.ip.neighbor.remove(string interfacename, string neighboraddr, string netstack, string version)
$esxcli.network.ip.netstack
$esxcli.network.ip.netstack.add(boolean disabled, string netstack)
$esxcli.network.ip.netstack.get(string netstack)
$esxcli.network.ip.netstack.list()
$esxcli.network.ip.netstack.remove(string netstack)
$esxcli.network.ip.netstack.set(string ccalgo, boolean enable, boolean ipv6enabled, long maxconn, string name, string netstack)
$esxcli.network.ip.route
$esxcli.network.ip.route.ipv4
$esxcli.network.ip.route.ipv4.add(string gateway, string netstack, string network)
$esxcli.network.ip.route.ipv4.list(string netstack)
$esxcli.network.ip.route.ipv4.remove(string gateway, string netstack, string network)
$esxcli.network.ip.route.ipv6
$esxcli.network.ip.route.ipv6.add(string gateway, string netstack, string network)
$esxcli.network.ip.route.ipv6.list(string netstack)
$esxcli.network.ip.route.ipv6.remove(string gateway, string netstack, string network)
$esxcli.network.ip.route.help()
$esxcli.network.ip.get()
$esxcli.network.ip.set(boolean ipv6enabled)
$esxcli.network.nic
$esxcli.network.nic.coalesce
$esxcli.network.nic.coalesce.get(string vmnic)
$esxcli.network.nic.coalesce.set(long rxmaxframes, long rxusecs, long txmaxframes, long txusecs, string vmnic)
$esxcli.network.nic.cso
$esxcli.network.nic.cso.get(string vmnic)
$esxcli.network.nic.cso.set(long enable, string vmnic)
$esxcli.network.nic.eeprom
$esxcli.network.nic.eeprom.change(string file, long magic, long offset, long value, string vmnic)
$esxcli.network.nic.eeprom.dump(long length, long offset, string vmnic)
$esxcli.network.nic.negotiate
$esxcli.network.nic.negotiate.restart(string vmnic)
$esxcli.network.nic.register
$esxcli.network.nic.register.dump(string vmnic)
$esxcli.network.nic.selftest
$esxcli.network.nic.selftest.run(long online, string vmnic)
$esxcli.network.nic.sg
$esxcli.network.nic.sg.get(string vmnic)
$esxcli.network.nic.sg.set(long enable, string vmnic)
$esxcli.network.nic.stats
$esxcli.network.nic.stats.get(string nicname)
$esxcli.network.nic.tso
$esxcli.network.nic.tso.get(string vmnic)
$esxcli.network.nic.tso.set(long enable, string vmnic)
$esxcli.network.nic.vlan
$esxcli.network.nic.vlan.stats
$esxcli.network.nic.vlan.stats.get(string nicname)
$esxcli.network.nic.vlan.stats.set(boolean enabled, string nicname)
$esxcli.network.nic.vlan.help()
$esxcli.network.nic.down(string nicname)
$esxcli.network.nic.get(string nicname)
$esxcli.network.nic.list()
$esxcli.network.nic.set(boolean auto, string duplex, long messagelevel, string nicname, long phyaddress, string port, long speed, string transceivertype, string wakeonlan)
$esxcli.network.nic.up(string nicname)
$esxcli.network.port
$esxcli.network.port.filter
$esxcli.network.port.filter.stats
$esxcli.network.port.filter.stats.get(long portid)
$esxcli.network.port.filter.help()
$esxcli.network.port.stats
$esxcli.network.port.stats.get(long portid)
$esxcli.network.port.help()
$esxcli.network.sriovnic
$esxcli.network.sriovnic.vf
$esxcli.network.sriovnic.vf.list(string nicname)
$esxcli.network.sriovnic.vf.stats(string nicname, long vfid)
$esxcli.network.sriovnic.list()
$esxcli.network.vm
$esxcli.network.vm.port
$esxcli.network.vm.port.list(long worldid)
$esxcli.network.vm.list()
$esxcli.network.vswitch
$esxcli.network.vswitch.dvs
$esxcli.network.vswitch.dvs.vmware
$esxcli.network.vswitch.dvs.vmware.lacp
$esxcli.network.vswitch.dvs.vmware.lacp.config
$esxcli.network.vswitch.dvs.vmware.lacp.config.get(string dvs)
$esxcli.network.vswitch.dvs.vmware.lacp.stats
$esxcli.network.vswitch.dvs.vmware.lacp.stats.get(string dvs)
$esxcli.network.vswitch.dvs.vmware.lacp.status
$esxcli.network.vswitch.dvs.vmware.lacp.status.get(string dvs)
$esxcli.network.vswitch.dvs.vmware.lacp.timeout
$esxcli.network.vswitch.dvs.vmware.lacp.timeout.set(long lagid, string nicname, boolean timeout, string vds)
$esxcli.network.vswitch.dvs.vmware.lacp.help()
$esxcli.network.vswitch.dvs.vmware.vxlan
$esxcli.network.vswitch.dvs.vmware.vxlan.config
$esxcli.network.vswitch.dvs.vmware.vxlan.config.stats
$esxcli.network.vswitch.dvs.vmware.vxlan.config.stats.get()
$esxcli.network.vswitch.dvs.vmware.vxlan.config.stats.set(long level)
$esxcli.network.vswitch.dvs.vmware.vxlan.config.help()
$esxcli.network.vswitch.dvs.vmware.vxlan.network
$esxcli.network.vswitch.dvs.vmware.vxlan.network.arp
$esxcli.network.vswitch.dvs.vmware.vxlan.network.arp.list(string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.arp.reset(string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.mac
$esxcli.network.vswitch.dvs.vmware.vxlan.network.mac.list(string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.mac.reset(string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.mtep
$esxcli.network.vswitch.dvs.vmware.vxlan.network.mtep.list(string mtepip, string segmentid, string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.port
$esxcli.network.vswitch.dvs.vmware.vxlan.network.port.stats
$esxcli.network.vswitch.dvs.vmware.vxlan.network.port.stats.list(string vdsname, string vdsportid, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.port.stats.reset(string vdsname, string vdsportid, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.port.list(string vdsname, string vdsportid, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.stats
$esxcli.network.vswitch.dvs.vmware.vxlan.network.stats.list(string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.stats.reset(string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.network.list(string vdsname, long vxlanid)
$esxcli.network.vswitch.dvs.vmware.vxlan.stats
$esxcli.network.vswitch.dvs.vmware.vxlan.stats.list(string vdsname)
$esxcli.network.vswitch.dvs.vmware.vxlan.stats.reset(string vdsname)
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.multicastgroup
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.multicastgroup.list(string vdsname, long vmknicid, string vmknicip, string vmknicname)
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.stats
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.stats.list(long endpointid, string vdsname, string vmknicip, string vmknicname)
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.stats.reset(long endpointid, string vdsname, string vmknicip, string vmknicname)
$esxcli.network.vswitch.dvs.vmware.vxlan.vmknic.list(long endpointid, string vdsname, string vmknicip, string vmknicname)
$esxcli.network.vswitch.dvs.vmware.vxlan.get()
$esxcli.network.vswitch.dvs.vmware.vxlan.list(string vdsname)
$esxcli.network.vswitch.dvs.vmware.list(string vdsname)
$esxcli.network.vswitch.dvs.help()
$esxcli.network.vswitch.standard
$esxcli.network.vswitch.standard.policy
$esxcli.network.vswitch.standard.policy.failover
$esxcli.network.vswitch.standard.policy.failover.get(string vswitchname)
$esxcli.network.vswitch.standard.policy.failover.set(string activeuplinks, boolean failback, string failuredetection, string loadbalancing, boolean notifyswitches, string standbyuplinks, string vswitchname)
$esxcli.network.vswitch.standard.policy.security
$esxcli.network.vswitch.standard.policy.security.get(string vswitchname)
$esxcli.network.vswitch.standard.policy.security.set(boolean allowforgedtransmits, boolean allowmacchange, boolean allowpromiscuous, string vswitchname)
$esxcli.network.vswitch.standard.policy.shaping
$esxcli.network.vswitch.standard.policy.shaping.get(string vswitchname)
$esxcli.network.vswitch.standard.policy.shaping.set(long avgbandwidth, long burstsize, boolean enabled, long peakbandwidth, string vswitchname)
$esxcli.network.vswitch.standard.policy.help()
$esxcli.network.vswitch.standard.portgroup
$esxcli.network.vswitch.standard.portgroup.policy
$esxcli.network.vswitch.standard.portgroup.policy.failover
$esxcli.network.vswitch.standard.portgroup.policy.failover.get(string portgroupname)
$esxcli.network.vswitch.standard.portgroup.policy.failover.set(string activeuplinks, boolean failback, string failuredetection, string loadbalancing, boolean notifyswitches, string portgroupname, string standbyuplinks, boolean usevswitch)
$esxcli.network.vswitch.standard.portgroup.policy.security
$esxcli.network.vswitch.standard.portgroup.policy.security.get(string portgroupname)
$esxcli.network.vswitch.standard.portgroup.policy.security.set(boolean allowforgedtransmits, boolean allowmacchange, boolean allowpromiscuous, string portgroupname, boolean usevswitch)
$esxcli.network.vswitch.standard.portgroup.policy.shaping
$esxcli.network.vswitch.standard.portgroup.policy.shaping.get(string portgroupname)
$esxcli.network.vswitch.standard.portgroup.policy.shaping.set(long avgbandwidth, long burstsize, boolean enabled, long peakbandwidth, string portgroupname, boolean usevswitch)
$esxcli.network.vswitch.standard.portgroup.policy.help()
$esxcli.network.vswitch.standard.portgroup.add(string portgroupname, string vswitchname)
$esxcli.network.vswitch.standard.portgroup.list()
$esxcli.network.vswitch.standard.portgroup.remove(string portgroupname, string vswitchname)
$esxcli.network.vswitch.standard.portgroup.set(string portgroupname, long vlanid)
$esxcli.network.vswitch.standard.uplink
$esxcli.network.vswitch.standard.uplink.add(string uplinkname, string vswitchname)
$esxcli.network.vswitch.standard.uplink.remove(string uplinkname, string vswitchname)
$esxcli.network.vswitch.standard.add(long ports, string vswitchname)
$esxcli.network.vswitch.standard.list(string vswitchname)
$esxcli.network.vswitch.standard.remove(string vswitchname)
$esxcli.network.vswitch.standard.set(string cdpstatus, long mtu, string vswitchname)
$esxcli.network.vswitch.help()
$esxcli.sched
$esxcli.sched.reliablemem
$esxcli.sched.reliablemem.get()
$esxcli.sched.swap
$esxcli.sched.swap.system
$esxcli.sched.swap.system.get()
$esxcli.sched.swap.system.set(boolean datastoreenabled, string datastorename, long datastoreorder, boolean hostcacheenabled, long hostcacheorder, boolean hostlocalswapenabled, long hostlocalswaporder)
$esxcli.sched.swap.help()
$esxcli.software
$esxcli.software.acceptance
$esxcli.software.acceptance.get()
$esxcli.software.acceptance.set(string level)
$esxcli.software.profile
$esxcli.software.profile.get(boolean rebootingimage)
$esxcli.software.profile.install(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, boolean oktoremove, string profile, string proxy)
$esxcli.software.profile.update(boolean allowdowngrades, string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string profile, string proxy)
$esxcli.software.profile.validate(string[] depot, string profile, string proxy)
$esxcli.software.sources
$esxcli.software.sources.profile
$esxcli.software.sources.profile.get(string[] depot, string profile, string proxy)
$esxcli.software.sources.profile.list(string[] depot, string proxy)
$esxcli.software.sources.vib
$esxcli.software.sources.vib.get(string[] depot, string proxy, string[] vibname, string[] viburl)
$esxcli.software.sources.vib.list(string[] depot, string proxy)
$esxcli.software.sources.help()
$esxcli.software.vib
$esxcli.software.vib.get(boolean rebootingimage, string[] vibname)
$esxcli.software.vib.install(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)
$esxcli.software.vib.list(boolean rebootingimage)
$esxcli.software.vib.remove(boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, string[] vibname)
$esxcli.software.vib.update(string[] depot, boolean dryrun, boolean force, boolean maintenancemode, boolean noliveinstall, boolean nosigcheck, string proxy, string[] vibname, string[] viburl)
$esxcli.storage
$esxcli.storage.core
$esxcli.storage.core.adapter
$esxcli.storage.core.adapter.stats
$esxcli.storage.core.adapter.stats.get(string adapter)
$esxcli.storage.core.adapter.list()
$esxcli.storage.core.adapter.rescan(string adapter, boolean all, boolean skipclaim, boolean skipfsscan, string type)
$esxcli.storage.core.claiming
$esxcli.storage.core.claiming.autoclaim(string claimruleclass, boolean enabled, boolean wait)
$esxcli.storage.core.claiming.reclaim(string device)
$esxcli.storage.core.claiming.unclaim(string adapter, long channel, string claimruleclass, string device, string driver, long lun, string model, string path, string plugin, long target, string type, string vendor)
$esxcli.storage.core.claimrule
$esxcli.storage.core.claimrule.add(string adapter, boolean autoassign, long channel, string claimruleclass, string device, string driver, boolean force, string ifunset, string iqn, long lun, string model, string plugin, long rule, long target, string transport, string type, string vendor, string wwnn, string wwpn)
$esxcli.storage.core.claimrule.convert(boolean commit)
$esxcli.storage.core.claimrule.list(string claimruleclass)
$esxcli.storage.core.claimrule.load(string claimruleclass)
$esxcli.storage.core.claimrule.move(string claimruleclass, long newrule, long rule)
$esxcli.storage.core.claimrule.remove(string claimruleclass, string plugin, long rule)
$esxcli.storage.core.claimrule.run(string adapter, long channel, string claimruleclass, string device, long lun, string path, long target, string type, boolean wait)
$esxcli.storage.core.device
$esxcli.storage.core.device.detached
$esxcli.storage.core.device.detached.list(string device)
$esxcli.storage.core.device.detached.remove(string device)
$esxcli.storage.core.device.partition
$esxcli.storage.core.device.partition.list(string device)
$esxcli.storage.core.device.partition.showguid(string device)
$esxcli.storage.core.device.smart
$esxcli.storage.core.device.smart.get(string devicename)
$esxcli.storage.core.device.stats
$esxcli.storage.core.device.stats.get(string device)
$esxcli.storage.core.device.vaai
$esxcli.storage.core.device.vaai.status
$esxcli.storage.core.device.vaai.status.get(string device)
$esxcli.storage.core.device.vaai.help()
$esxcli.storage.core.device.world
$esxcli.storage.core.device.world.list(string device)
$esxcli.storage.core.device.list(string device)
$esxcli.storage.core.device.set(boolean defaultname, string device, string name, boolean nopersist, long queuefullsamplesize, long queuefullthreshold, long schednumreqoutstanding, string state)
$esxcli.storage.core.device.setconfig(boolean detached, string device, boolean perenniallyreserved)
$esxcli.storage.core.path
$esxcli.storage.core.path.stats
$esxcli.storage.core.path.stats.get(string path)
$esxcli.storage.core.path.list(string device, string path)
$esxcli.storage.core.path.set(string path, string state)
$esxcli.storage.core.plugin
$esxcli.storage.core.plugin.registration
$esxcli.storage.core.plugin.registration.add(string dependencies, string fullpath, string modulename, string pluginclass, string pluginname)
$esxcli.storage.core.plugin.registration.list(string modulename, string pluginclass)
$esxcli.storage.core.plugin.registration.remove(string modulename)
$esxcli.storage.core.plugin.list(string pluginclass)
$esxcli.storage.core.help()
$esxcli.storage.filesystem
$esxcli.storage.filesystem.automount()
$esxcli.storage.filesystem.list()
$esxcli.storage.filesystem.mount(boolean nopersist, string volumelabel, string volumeuuid)
$esxcli.storage.filesystem.rescan()
$esxcli.storage.filesystem.unmount(boolean nopersist, string volumelabel, string volumepath, string volumeuuid)
$esxcli.storage.nfs
$esxcli.storage.nfs.param
$esxcli.storage.nfs.param.get(string volumename)
$esxcli.storage.nfs.param.set(long maxqueuedepth, string volumename)
$esxcli.storage.nfs.add(string host, boolean readonly, string share, string volumename)
$esxcli.storage.nfs.list()
$esxcli.storage.nfs.remove(string volumename)
$esxcli.storage.nmp
$esxcli.storage.nmp.device
$esxcli.storage.nmp.device.list(string device)
$esxcli.storage.nmp.device.set(boolean default, string device, string psp)
$esxcli.storage.nmp.path
$esxcli.storage.nmp.path.list(string device, string path)
$esxcli.storage.nmp.psp
$esxcli.storage.nmp.psp.fixed
$esxcli.storage.nmp.psp.fixed.deviceconfig
$esxcli.storage.nmp.psp.fixed.deviceconfig.get(string device)
$esxcli.storage.nmp.psp.fixed.deviceconfig.set(boolean cfgfile, boolean default, string device, string path)
$esxcli.storage.nmp.psp.fixed.help()
$esxcli.storage.nmp.psp.generic
$esxcli.storage.nmp.psp.generic.deviceconfig
$esxcli.storage.nmp.psp.generic.deviceconfig.get(string device)
$esxcli.storage.nmp.psp.generic.deviceconfig.set(boolean cfgfile, string config, string device)
$esxcli.storage.nmp.psp.generic.pathconfig
$esxcli.storage.nmp.psp.generic.pathconfig.get(string path)
$esxcli.storage.nmp.psp.generic.pathconfig.set(boolean cfgfile, string config, string path)
$esxcli.storage.nmp.psp.generic.help()
$esxcli.storage.nmp.psp.roundrobin
$esxcli.storage.nmp.psp.roundrobin.deviceconfig
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.get(string device)
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set(long bytes, boolean cfgfile, string device, long iops, string type, boolean useano)
$esxcli.storage.nmp.psp.roundrobin.help()
$esxcli.storage.nmp.psp.list()
$esxcli.storage.nmp.satp
$esxcli.storage.nmp.satp.generic
$esxcli.storage.nmp.satp.generic.deviceconfig
$esxcli.storage.nmp.satp.generic.deviceconfig.get(string device)
$esxcli.storage.nmp.satp.generic.deviceconfig.set(string config, string device)
$esxcli.storage.nmp.satp.generic.pathconfig
$esxcli.storage.nmp.satp.generic.pathconfig.get(string path)
$esxcli.storage.nmp.satp.generic.pathconfig.set(string config, string path)
$esxcli.storage.nmp.satp.generic.help()
$esxcli.storage.nmp.satp.rule
$esxcli.storage.nmp.satp.rule.add(boolean boot, string claimoption, string description, string device, string driver, boolean force, string model, string option, string psp, string pspoption, string satp, string transport, string type, string vendor)
$esxcli.storage.nmp.satp.rule.list(string satp)
$esxcli.storage.nmp.satp.rule.remove(boolean boot, string claimoption, string description, string device, string driver, string model, string option, string psp, string pspoption, string satp, string transport, string type, string vendor)
$esxcli.storage.nmp.satp.list()
$esxcli.storage.nmp.satp.set(boolean boot, string defaultpsp, string satp)
$esxcli.storage.nmp.help()
$esxcli.storage.san
$esxcli.storage.san.fc
$esxcli.storage.san.fc.events
$esxcli.storage.san.fc.events.clear(string adapter)
$esxcli.storage.san.fc.events.get(string adapter)
$esxcli.storage.san.fc.stats
$esxcli.storage.san.fc.stats.get(string adapter)
$esxcli.storage.san.fc.list(string adapter)
$esxcli.storage.san.fc.reset(string adapter)
$esxcli.storage.san.fcoe
$esxcli.storage.san.fcoe.stats
$esxcli.storage.san.fcoe.stats.get(string adapter)
$esxcli.storage.san.fcoe.list(string adapter)
$esxcli.storage.san.fcoe.reset(string adapter)
$esxcli.storage.san.iscsi
$esxcli.storage.san.iscsi.stats
$esxcli.storage.san.iscsi.stats.get(string adapter)
$esxcli.storage.san.iscsi.list(string adapter)
$esxcli.storage.san.sas
$esxcli.storage.san.sas.stats
$esxcli.storage.san.sas.stats.get(string adapter)
$esxcli.storage.san.sas.list(string adapter)
$esxcli.storage.san.sas.reset(string adapter)
$esxcli.storage.san.help()
$esxcli.storage.vflash
$esxcli.storage.vflash.cache
$esxcli.storage.vflash.cache.stats
$esxcli.storage.vflash.cache.stats.get(string cachename, string modulename)
$esxcli.storage.vflash.cache.stats.reset(string cachename, string modulename)
$esxcli.storage.vflash.cache.get(string cachename, string modulename)
$esxcli.storage.vflash.cache.list(string modulename)
$esxcli.storage.vflash.device
$esxcli.storage.vflash.device.list(boolean eligible, boolean used)
$esxcli.storage.vflash.module
$esxcli.storage.vflash.module.stats
$esxcli.storage.vflash.module.stats.get(string modulename)
$esxcli.storage.vflash.module.get(string modulename)
$esxcli.storage.vflash.module.list()
$esxcli.storage.vflash.help()
$esxcli.storage.vmfs
$esxcli.storage.vmfs.extent
$esxcli.storage.vmfs.extent.list()
$esxcli.storage.vmfs.snapshot
$esxcli.storage.vmfs.snapshot.extent
$esxcli.storage.vmfs.snapshot.extent.list(string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.snapshot.list(string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.snapshot.mount(boolean nopersist, string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.snapshot.resignature(string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.unmap(long reclaimunit, string volumelabel, string volumeuuid)
$esxcli.storage.vmfs.upgrade(string volumelabel, string volumeuuid)
$esxcli.system
$esxcli.system.boot
$esxcli.system.boot.device
$esxcli.system.boot.device.get()
$esxcli.system.boot.help()
$esxcli.system.coredump
$esxcli.system.coredump.file
$esxcli.system.coredump.file.add(boolean auto, string datastore, string file, long size)
$esxcli.system.coredump.file.get()
$esxcli.system.coredump.file.list()
$esxcli.system.coredump.file.remove(string file, boolean force)
$esxcli.system.coredump.file.set(boolean enable, string path, boolean smart, boolean unconfigure)
$esxcli.system.coredump.network
$esxcli.system.coredump.network.check()
$esxcli.system.coredump.network.get()
$esxcli.system.coredump.network.set(boolean enable, string interfacename, string serveripv4, long serverport)
$esxcli.system.coredump.partition
$esxcli.system.coredump.partition.get()
$esxcli.system.coredump.partition.list()
$esxcli.system.coredump.partition.set(boolean enable, string partition, boolean smart, boolean unconfigure)
$esxcli.system.coredump.help()
$esxcli.system.hostname
$esxcli.system.hostname.get()
$esxcli.system.hostname.set(string domain, string fqdn, string host)
$esxcli.system.maintenanceMode
$esxcli.system.maintenanceMode.get()
$esxcli.system.maintenanceMode.set(boolean enable, long timeout)
$esxcli.system.module
$esxcli.system.module.parameters
$esxcli.system.module.parameters.list(string module)
$esxcli.system.module.parameters.set(boolean force, string module, string parameterstring)
$esxcli.system.module.get(string module)
$esxcli.system.module.list(boolean enabled, boolean loaded)
$esxcli.system.module.load(boolean force, string module)
$esxcli.system.module.set(boolean enabled, boolean force, string module)
$esxcli.system.process
$esxcli.system.process.stats
$esxcli.system.process.stats.load
$esxcli.system.process.stats.load.get()
$esxcli.system.process.stats.running
$esxcli.system.process.stats.running.get()
$esxcli.system.process.stats.help()
$esxcli.system.process.list()
$esxcli.system.secpolicy
$esxcli.system.secpolicy.domain
$esxcli.system.secpolicy.domain.list()
$esxcli.system.secpolicy.domain.set(boolean alldomains, string level, string name)
$esxcli.system.secpolicy.help()
$esxcli.system.security
$esxcli.system.security.certificatestore
$esxcli.system.security.certificatestore.add(string filename)
$esxcli.system.security.certificatestore.list()
$esxcli.system.security.certificatestore.remove(string issuer, string serial)
$esxcli.system.security.help()
$esxcli.system.settings
$esxcli.system.settings.advanced
$esxcli.system.settings.advanced.list(boolean delta, string option, string tree)
$esxcli.system.settings.advanced.set(boolean default, long intvalue, string option, string stringvalue)
$esxcli.system.settings.kernel
$esxcli.system.settings.kernel.list(boolean delta, string option)
$esxcli.system.settings.kernel.set(string setting, string value)
$esxcli.system.settings.keyboard
$esxcli.system.settings.keyboard.layout
$esxcli.system.settings.keyboard.layout.get()
$esxcli.system.settings.keyboard.layout.list()
$esxcli.system.settings.keyboard.layout.set(string layout, boolean nopersist)
$esxcli.system.settings.keyboard.help()
$esxcli.system.settings.help()
$esxcli.system.shutdown
$esxcli.system.shutdown.poweroff(long delay, string reason)
$esxcli.system.shutdown.reboot(long delay, string reason)
$esxcli.system.snmp
$esxcli.system.snmp.get()
$esxcli.system.snmp.hash(string authhash, string privhash, boolean rawsecret)
$esxcli.system.snmp.set(string authentication, string communities, boolean enable, string engineid, string hwsrc, string loglevel, string notraps, long port, string privacy, string remoteusers, boolean reset, string syscontact, string syslocation, string targets, string users, string v3targets)
$esxcli.system.snmp.test(string authhash, string privhash, boolean rawsecret, string user)
$esxcli.system.stats
$esxcli.system.stats.uptime
$esxcli.system.stats.uptime.get()
$esxcli.system.stats.help()
$esxcli.system.syslog
$esxcli.system.syslog.config
$esxcli.system.syslog.config.logger
$esxcli.system.syslog.config.logger.list()
$esxcli.system.syslog.config.logger.set(string id, string reset, long rotate, long size)
$esxcli.system.syslog.config.get()
$esxcli.system.syslog.config.set(long defaultrotate, long defaultsize, long defaulttimeout, string logdir, boolean logdirunique, string loghost, string reset)
$esxcli.system.syslog.mark(string message)
$esxcli.system.syslog.reload()
$esxcli.system.time
$esxcli.system.time.get()
$esxcli.system.time.set(long day, long hour, long min, long month, long sec, long year)
$esxcli.system.uuid
$esxcli.system.uuid.get()
$esxcli.system.version
$esxcli.system.version.get()
$esxcli.system.visorfs
$esxcli.system.visorfs.ramdisk
$esxcli.system.visorfs.ramdisk.add(long maxsize, long minsize, string name, string permissions, string target)
$esxcli.system.visorfs.ramdisk.list()
$esxcli.system.visorfs.ramdisk.remove(string target)
$esxcli.system.visorfs.tardisk
$esxcli.system.visorfs.tardisk.list()
$esxcli.system.visorfs.get()
$esxcli.system.welcomemsg
$esxcli.system.welcomemsg.get()
$esxcli.system.welcomemsg.set(string message)
$esxcli.vm
$esxcli.vm.process
$esxcli.vm.process.kill(string type, long worldid)
$esxcli.vm.process.list()
$esxcli.vsan
$esxcli.vsan.cluster
$esxcli.vsan.cluster.get()
$esxcli.vsan.cluster.join(string clusteruuid, boolean wait)
$esxcli.vsan.cluster.leave()
$esxcli.vsan.cluster.restore()
$esxcli.vsan.datastore
$esxcli.vsan.datastore.name
$esxcli.vsan.datastore.name.get()
$esxcli.vsan.datastore.name.set(string newname)
$esxcli.vsan.datastore.help()
$esxcli.vsan.maintenancemode
$esxcli.vsan.maintenancemode.cancel()
$esxcli.vsan.network
$esxcli.vsan.network.ipv4
$esxcli.vsan.network.ipv4.add(string agentmcaddr, long agentmcport, string interfacename, string mastermcaddr, long mastermcport, long multicastttl)
$esxcli.vsan.network.ipv4.remove(boolean force, string interfacename)
$esxcli.vsan.network.ipv4.set(string agentmcaddr, long agentmcport, string interfacename, string mastermcaddr, long mastermcport, long multicastttl)
$esxcli.vsan.network.clear()
$esxcli.vsan.network.list()
$esxcli.vsan.network.remove(boolean force, string interfacename)
$esxcli.vsan.network.restore()
$esxcli.vsan.policy
$esxcli.vsan.policy.cleardefault()
$esxcli.vsan.policy.getdefault(string policyclass)
$esxcli.vsan.policy.setdefault(string policy, string policyclass)
$esxcli.vsan.storage
$esxcli.vsan.storage.automode
$esxcli.vsan.storage.automode.get()
$esxcli.vsan.storage.automode.set(boolean enabled)
$esxcli.vsan.storage.add(string[] disks, string ssd)
$esxcli.vsan.storage.list(string device)
$esxcli.vsan.storage.remove(string disk, string ssd, string uuid)
$esxcli.vsan.trace
$esxcli.vsan.trace.set(long numfiles, string path, boolean reset, long size)

Friday, August 7, 2015

Finding VMs Affected by HA Failover for a Specific Cluster

While vSphere HA is a lifesaver in terms of managing and automatically recovering from host failures, finding out the VMs that were impacted is not as easy. In order to find out which VMs were restarted successfully by HA, you would have to drill down into the vCenter event logs. This is normally not an issue for small and medium environments, but could be an issue for larger environments where many events are generated, causing the logs to roll over.

Luckily, PowerCLI can be used to get a list of all VMs affected by a HA failover. The original script was obtained from here, and has been modified to allow a specific cluster from being specified.


Pre-requisites:

  • Name of the vCenter Server where the failover occurred
  • Name of the ESXi cluster where the failover occurred
  • Hainfo.ps1 script
  • PowerCLI 5.1 or higher installed
  • A minimum of read-only access to the vCenter

Usage:

  1. Open a PowerCLI console
  2. Change the working directory to where the hainfo.ps1 script is located
  3. Run the powershell script with the required parameters shown below

    .\hainfo.ps1 –vcenter vcenter_name –cluster cluster_name

    By default, the script above will look at all vCenter Events within the last 7 days up to a maximum of 100,000 events and will search for any HA failover events experienced by the specified cluster.
  4. Observe the output to the console for the list of VMs affected by the HA failover
  5. If there are too many affected VMs listed in the console, the output can be piped to a text file

    .\hainfo.ps1 –vcenter vcenter_name –cluster cluster_name > c:\results.txt


hainfo.ps1 Script:


param(
    [string]$vcenter = $null,
[string]$cluster = $null,
    [int]$last = 7,
[int]$maxEvents = 100000,
    [switch]$help = $false
)

Write-Host "`nScript to generate list of successful and failed VM restart attempts after a HA host failure."

if ($help)
{
Write-Host "`nRequired parameters:
`n-vcenter server_name connect to vCenter server servername
`n-cluster cluster_name check for HA failovers in the cluster_name cluster
`n
`nOptional Parameters:
`n-help display this help
`n-last n analyze events from the last n days (default is 7)
`n-maxEvents n analyze a maximum of n events (default is 100,000)
"
exit
}
else
{
Write-Host "`n(Use -help for list of parameters)"
}

if (!(get-pssnapin -name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue )) { add-pssnapin "VMware.VimAutomation.Core" }

Write-Host "`nConnecting to vCenter server $vcenter ..."
try
{
Connect-VIServer $vcenter | Out-Null
Write-Host "Success: Connected to vCenter Server $vcenter . "
}
Catch
{
Write-Host "Error: Unable to connect to vCenter Server $vcenter . "
exit
}


$Date = (Get-Date).AddDays(-$last)


write-host "`nList of Successful VM restarts on cluster $cluster"

Get-VIEvent -maxsamples $maxEvents -Start $Date -type warning | Where {($_.EventTypeID -eq "com.vmware.vc.ha.VmRestartedByHAEvent") -and ($_.ComputeResource.Name -eq $cluster)} | Select CreatedTime, ObjectName,FullFormattedMessage

write-host "`n`nList of Unsuccessful VM restarts on cluster $cluster"

Get-VIEvent -maxsamples $maxEvents -Start $Date -type warning | Where {($_.FullFormattedMessage -like "vSphere HA stopped trying*") -and ($_.ComputeResource.Name -eq $cluster)} | Select CreatedTime, ObjectName,FullFormattedMessage



Disconnect-VIServer -Force -Confirm:$false



Optional Parameters

Optional Parameters and their defaults are shown below:

-help display the help menu
-last n analyze events from the last n days (default is 7)

-maxEvents n analyze a maximum of n events (default is 100,000)