Get service status from remote server using powershell

女生的网名这么多〃 提交于 2019-12-03 06:45:31

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

$cred = get-Credential -credential <your domain user here>
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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!