PowerCLI

 View Only
  • 1.  Vcenter services

    Posted 28 days ago

    HI.

    I am looking to see if it is possible to check status of vcenter services using powercli, looking to check status of services that "service-control" have eyes on it like what is the status of vmware-vpxd and other , also if status is not running who di I restart the service .

    Thanks a bunch 



  • 2.  RE: Vcenter services

    Posted 25 days ago

    Hi Fborges555.

    I am working on something similar.  However, I cannot get the status to be returned.  Parts of this may help.

     # Reconnect to the vCenter
            Write-Host "Reconnecting to $vcenter" -ForegroundColor Green
            Connect-VIServer -Server $vcenter -Credential $VMWareCredentials -Force
            # Wait for the vCenter vmware-content-library service to start
            Write-Host "Waiting for vmware-content-library service to start on $vcenter" -ForegroundColor Green
            $vcenterServiceManager = Get-View -Id (Get-View ServiceInstance).Content.ServiceManager
            $vmwareContentLibraryService = $vcenterServiceManager.QueryServiceList() | Where-Object { $_.ServiceName -eq "com.vmware.content.library" }
            $serviceStatus = $vmwareContentLibraryService.ServiceStatus

    I haven't tried this but this should start the service:

    Start-Service -Name vpxd




  • 3.  RE: Vcenter services

    Posted 24 days ago

    H.

    Thanks for jumping in chief, I have the same issue, status does not show/bring anything. - anyone else that has used this approach can pitch in?

    we need help gurus

    thanks a bunch 




  • 4.  RE: Vcenter services

    Posted 23 days ago

    Hi,

    Never used powercli to check vcsa services, but I found this post from @LucD with a script that dose the trick. (You'll need to install and import the Posh-SSH module.)

    You can either run the script directly or wrap it in a function:

    function Get-VCSAServiceStatus {
        param (
            [string]$vmName,
            [string]$user,
            [string]$pswd
        )

        $cmd = @'
    service-control --status
    '@

        $cred = [PSCredential]::new($user, (ConvertTo-SecureString -String $pswd -AsPlainText -Force))
        
        $session = New-SSHSession -ComputerName $vmName -Credential $cred -AcceptKey
        
        Invoke-SSHCommand -SSHSession $session -Command $cmd | Select-Object -ExpandProperty Output
        
        Remove-SSHSession -SSHSession $session | Out-Null
    }


    And then run it like this:

    Get-VCSAServiceStatus -vmName 'vcsa.my.domain' -user 'root' -pswd 'VMware1!'