Help with script cmdlet (get-service) on remote computer

Hi all,
some help would be appreciated if possible. when i run the below cmdlet i get the following output

$service = (Get-Service -Name “SepMasterService”)

Status Name DisplayName

Running SepMasterService Symantec Endpoint Protection

however if i run the below through a function using Invoke-Command i get the following error
$serviceName = “SepMasterService”
$Service = (Get-service -Name $serviceName)
i get the below error

Cannot find any service with service name ‘System.ServiceProcess.ServiceController’.
+ CategoryInfo : ObjectNotFound: (System.ServiceProcess.ServiceController:String) [Get-Service], ServiceCommandException
+ FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

looks like a pretty straight forward commond. what am I doing wrong here ?


Could you check this command

Get-Service -ComputerName $serverName -Name “SepMasterService”

Thanks Mate.
Got it working. I used DisplayName instead

    [String]$displayName = "Symantec Endpoint Protection",
    [String]$Status = "Stopped"
    $Service = (Get-service -DisplayName $displayName)