Get service status from remote server using powershell

前端 未结 4 790
刺人心
刺人心 2021-02-06 01:27

How to get the service status for a remote computer that needs a user name and password to log in?

I am trying to find a solution using the following code:

4条回答
  •  有刺的猬
    2021-02-06 01:56

    As far as I know, Get-Service doesn't accept a credential parameter. However, you can do it through WMI:

    $cred = get-Credential -credential 
    Get-WMIObject Win32_Service -computer $computer -credential $cred
    

    Update after comment:

    You can save credentials as a securestring into a file, and then reload it for manually creating a credential without having a prompt. See information here.

提交回复
热议问题