====== ESXi - PowerCLI ======
===== Connect =====
//more in this [[https://blogs.vmware.com/PowerCLI/2013/03/back-to-basics-connecting-to-vcenter-or-a-vsphere-host.html|VMware PowerCLI Blog post]]//
Components used in the following examples:
* Windows with installed vCenter Server: **myWinvCenter01**
* vCenter deployed as VCSA: **myVCSA01**
* User in vCenter to connect with: **myvCenterUser**
* Related user password: **myvCenterPassword**
==== Windows vCenter Server ====
Connect-VIServer myWinvCenter01
#...
Disconnect-VIServer -Force -Confirm:$false
==== vCenter Server Appliance ====
Credentials have to be stored once per Windows User:
New-VICredentialStoreItem -Host myVCSA01 -User myvCenterUser -Password myvCenterPassword
Connect-VIServer -Server myVCSA01 -User myvCenterUser
#...
Disconnect-VIServer -Force -Confirm:$false
===== Hardware-Info =====
==== Show physical disks on HP hosts ====
(Get-EsxCli -VMHost myVMHost).hpssacli.cmd("ctrl slot=0 pd all show")
===== Host Services =====
SSH (TSM-SSH) is used in the following examples on host myHost.
==== Start ====
Start-VMHostService -HostService (Get-VMHost myHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH" } )
==== Stop ====
Stop-VMHostService -HostService (Get-VMHost myHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH" } ) -Confirm:$false
==== Status ====
Get-VMHost myHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH" }
===== Already connected to vCenter? =====
if($Global:DefaultVIServer) {
"Connected."
} else {
"Not connected."
}