Difference between revisions of "Script Extracts and Examples (PowerCLI)"

Jump to navigation Jump to search
m
Anomise
m (→‎ESX Host: Added link)
m (Anomise)
Line 16: Line 16:


<source lang="powershell">
<source lang="powershell">
[vSphere PowerCLI] E:\> get-vm -name "winstg"
[vSphere PowerCLI] E:\> get-vm -name "vserver1"


Name                PowerState Num CPUs Memory (MB)
Name                PowerState Num CPUs Memory (MB)
----                ---------- -------- -----------
----                ---------- -------- -----------
winstg               PoweredOn  1        756
vserver1               PoweredOn  1        756




[vSphere PowerCLI] E:\> get-vm -name "winstg" | Format-List *
[vSphere PowerCLI] E:\> get-vm -name "vserver1" | Format-List *


PowerState          : PoweredOn
PowerState          : PoweredOn
Line 34: Line 34:
HardDisks          : {Hard Disk 1}
HardDisks          : {Hard Disk 1}
NetworkAdapters    : {Network Adapter 1}
NetworkAdapters    : {Network Adapter 1}
Host                : uklonesxt1.datastream.com
Host                : esx1.domain.com
HostId              : HostSystem-host-301
HostId              : HostSystem-host-301
HARestartPriority  : ClusterRestartPriority
HARestartPriority  : ClusterRestartPriority
Line 41: Line 41:
CustomFields        : {}
CustomFields        : {}
Id                  : VirtualMachine-vm-25136
Id                  : VirtualMachine-vm-25136
Name                : winstg
Name                : vserver1




[vSphere PowerCLI] E:\> get-vm -name "ukt1ewapilp1" | Format-List *
[vSphere PowerCLI] E:\> get-vm -name "vserver2" | Format-List *


PowerState          : PoweredOff
PowerState          : PoweredOff
Line 55: Line 55:
HardDisks          : {Hard Disk 1}
HardDisks          : {Hard Disk 1}
NetworkAdapters    : {Network Adapter 1, Network Adapter 2, Network Adapter 3}
NetworkAdapters    : {Network Adapter 1, Network Adapter 2, Network Adapter 3}
Host                : uklonesxtml1.datastream.com
Host                : vserver2.domain.com
HostId              : HostSystem-host-662
HostId              : HostSystem-host-662
HARestartPriority  : ClusterRestartPriority
HARestartPriority  : ClusterRestartPriority
Line 62: Line 62:
CustomFields        : {}
CustomFields        : {}
Id                  : VirtualMachine-vm-697
Id                  : VirtualMachine-vm-697
Name                : ukt1ewapilp1
Name                : vserver2




[vSphere PowerCLI] E:\> get-vm -name "ukt1ewapilp1" | ForEach-Object {$_.NetworkAdapters}
[vSphere PowerCLI] E:\> get-vm -name "vserver2" | ForEach-Object {$_.NetworkAdapters}


MacAddress      : 00:50:56:89:40:59
MacAddress      : 00:50:AB:CD:40:59
WakeOnLanEnabled : True
WakeOnLanEnabled : True
NetworkName      : PubLBFE2_52.128
NetworkName      : Some_Network
Type            : Flexible
Type            : Flexible
ConnectionState  : VMware.VimAutomation.Client20.ConnectInfoImpl
ConnectionState  : VMware.VimAutomation.Client20.ConnectInfoImpl
Line 75: Line 75:
Name            : Network Adapter 1
Name            : Network Adapter 1


MacAddress      : 00:50:56:89:55:40
MacAddress      : 00:50:AB:CD:55:40
WakeOnLanEnabled : True
WakeOnLanEnabled : True
NetworkName      : PubLBBE1_52.192
NetworkName      : Another_Network
Type            : Flexible
Type            : Flexible
ConnectionState  : VMware.VimAutomation.Client20.ConnectInfoImpl
ConnectionState  : VMware.VimAutomation.Client20.ConnectInfoImpl
Line 83: Line 83:
Name            : Network Adapter 2
Name            : Network Adapter 2


MacAddress      : 00:50:56:89:56:da
MacAddress      : 00:50:AB:CD:56:da
WakeOnLanEnabled : True
WakeOnLanEnabled : True
NetworkName      : PubHostBE2_49.192
NetworkName      : Yet_Another_Network
Type            : Flexible
Type            : Flexible
ConnectionState  : VMware.VimAutomation.Client20.ConnectInfoImpl
ConnectionState  : VMware.VimAutomation.Client20.ConnectInfoImpl
Line 104: Line 104:
| Get list of VM's, sorted by name
| Get list of VM's, sorted by name
|-
|-
| <code> get-vmguest -VM (get-vm -name "winstg") </code>  
| <code> get-vmguest -VM (get-vm -name "vserver1") </code>  
| Get VM guest info (IP address, OS)
| Get VM guest info (IP address, OS)
|-
|-
| <code> Get-VM "winstg" <nowiki>|</nowiki> %{(Get-View $_.Id).config.uuid} </code>  
| <code> Get-VM "vserver1" <nowiki>|</nowiki> %{(Get-View $_.Id).config.uuid} </code>  
| Get VM's UUID
| Get VM's UUID
|-
|-
| <code> Shutdown-VMGuest -VM (get-vm -name "winstg") </code>  
| <code> Shutdown-VMGuest -VM (get-vm -name "vserver1") </code>  
| Sends OS shutdown command via VM Tools
| Sends OS shutdown command via VM Tools
|}
|}
Line 119: Line 119:
! Command    !! Description
! Command    !! Description
|-
|-
| <code> get-vmhost -name uklonesxt1* <nowiki>|</nowiki> %{(Get-View $_.ID).Config.Product} </code>  
| <code> get-vmhost -name esxt1* <nowiki>|</nowiki> %{(Get-View $_.ID).Config.Product} </code>  
| Get ESX software version (inc build no)
| Get ESX software version (inc build no)
|-
|-
| <code> Get-ScsiLun -VMHost uklonesxt1* -LunType disk </code>  
| <code> Get-ScsiLun -VMHost esxt1* -LunType disk </code>  
| Get ESX disk VML ID's (SAN ID are a part of the VML - useful for identifying LUN's with SAN team). See [[ESX#SAN_LUN_ID|ESX SAN LUN ID]]
| Get ESX disk VML ID's (SAN ID are a part of the VML - useful for identifying LUN's with SAN team). See [[ESX#SAN_LUN_ID|ESX SAN LUN ID]]
|-
|-
| <code> Get-ScsiLun -VMHost uklonesxt1* -LunType disk <nowiki>|</nowiki> Get-ScsiLunPath </code>  
| <code> Get-ScsiLun -VMHost esxt1* -LunType disk <nowiki>|</nowiki> Get-ScsiLunPath </code>  
| Get ESX SCSI paths info
| Get ESX SCSI paths info
|}
|}

Navigation menu