Get service status from remote server using powershell

前端 未结 4 818
刺人心
刺人心 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:05

    Just like Morton's answer, but using New-PSDrive for the share and Remove the share to tidy up.

    New-PSDrive -Name tempDriveName –PSProvider FileSystem –Root “\\server\c$” -Credential $Cred
    $service = Get-Service -Name $serviceName -ComputerName $MachineName 
    Remove-PSDrive -Name tempDriveName
    

提交回复
热议问题