Alternative to Get-Service for Remote Computer in Powershell V6.0

426 views Asked by At

I have a script that uses Get-Service to see if a particular service exists and is running on a group of computers.

Get-Service -Name "ServiceName" -Computername "PCName"

In Powershell V6.0 the Get-Service cmdlet doesn't have the -Computername parameter. I can't seem to find another way to see the status of a service on a remote computer in Powershell V6. The computers I am checking don't have Powershell Remoting enabled on them.

1

There are 1 answers

1
AudioBubble On

You can find more details on how you run remote commands in PowerShell 6+ here.

In your specific example you can try using Invoke-Command:

Invoke-Command -ComputerName PCName -ScriptBlock {Get-Service -Name "ServiceName"}