Get service status from remote server using powershell

前端 未结 4 811
刺人心
刺人心 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 02:15

    This also works:

    net use \\server\c$ $password /USER:$username
    $service = Get-Service $serviceName -ComputerName $server
    

    Note that password should not be in a secure string.

提交回复
热议问题