Is there a way I can check if a service exists on a vmguest, using powercli?
I found many ways to do this using powershell commands, but I want to know if I can do it using powercli.
Thanks
If you have the VMware Tools installed on the VMs, you can use the Invoke-VMScript cmdlet to launch a PowerShell script inside the guest OS.
$vm = Get-VM -Name MyVM
$cmd = "Get-Service -Name WinRM"
Invoke-VMScript -VM $vm -ScriptText $cmd
Depending on the account under which you run the script, you might have to use the GuestCredential parameter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If you have the VMware Tools installed on the VMs, you can use the Invoke-VMScript cmdlet to launch a PowerShell script inside the guest OS.
$vm = Get-VM -Name MyVM
$cmd = "Get-Service -Name WinRM"
Invoke-VMScript -VM $vm -ScriptText $cmd
Depending on the account under which you run the script, you might have to use the GuestCredential parameter
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Here is a slightly different way, and adding the guest credentials
$vm = get-vm -Name MyVM
$cmd = "sc query <servicename>"
$GuestUsername = "guestUN"
$GuestPassword = "GuestPWD"
Invoke-VMScript -VM $VM -ScriptText $cmd -GuestUser $GuestUsername -GuestPassword $GuestPassword
I do this away:
Get-Service -ComputerName (Get-View -id (Get-VM VMNAME).Id).guest.hostname
Bye.