HI .
The only post in this regard I found was in 2018, with no resolution, has this been possible after all these years? restart all services in vcenter using powercli.
Thanks
Since the VCSA has the VMware Tools running, you can use Invoke-VMSCcipt.
You just have to set some environment variables for service-control to run (it is a phyton script).
$vcsaName = 'vcsa'
$user = 'root'
$cmd = @'
export VMWARE_PYTHON_PATH=/usr/lib/vmware/site-packages
export VMWARE_LOG_DIR=/var/log
export VMWARE_DATA_DIR=/storage
export VMWARE_CFG_DIR=/etc/vmware
service-control --start --all
'@
$vm = Get-VM -Name $vcsaName
$viCred = Get-VICredentialStoreItem -Host $vm.Guest.HostName -User $user
$cred = New-Object -TypeName PSCredential -ArgumentList $user,(ConvertTo-SecureString -String $viCred.Password -AsPlainText -Force)
Invoke-VMScript -VM $vm -ScriptText $cmd -ScriptType bash -GuestCredential $cred
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Since the VCSA has the VMware Tools running, you can use Invoke-VMSCcipt.
You just have to set some environment variables for service-control to run (it is a phyton script).
$vcsaName = 'vcsa'
$user = 'root'
$cmd = @'
export VMWARE_PYTHON_PATH=/usr/lib/vmware/site-packages
export VMWARE_LOG_DIR=/var/log
export VMWARE_DATA_DIR=/storage
export VMWARE_CFG_DIR=/etc/vmware
service-control --start --all
'@
$vm = Get-VM -Name $vcsaName
$viCred = Get-VICredentialStoreItem -Host $vm.Guest.HostName -User $user
$cred = New-Object -TypeName PSCredential -ArgumentList $user,(ConvertTo-SecureString -String $viCred.Password -AsPlainText -Force)
Invoke-VMScript -VM $vm -ScriptText $cmd -ScriptType bash -GuestCredential $cred
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
VCSA service restarts is one of the new features of PowerCLI 12.5 I believe - PowerCLI 12.5 - What's New - VMware PowerCLI Blog
I haven't tested this myself yet - so test first or use at your own risk - but I imagine a restart all would go something like:
Connect-VIServer vcenterservername
Get-VIApplianceService -State Started | Restart-VIApplianceService
That cmdlet returns all services running on the VCSA, not just the once covered with service-control.
For example ntpd, sendmail, and 12 others are included.
You should have tested that cmdlet ![]()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You're correct...I did put a caveat though ![]()
Interestingly, unless I'm mistaken, there are also some covered by service-control missing now that I'm doing a side-by-side (vpxd among them) - guess those cmdlets are still a WIP.
Yes, indeed.
That's why I suggested the Invoke-VMScript solution ![]()
And yes, you did put a caveat.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
