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

This topic contains 2 replies, has 2 voices, and was last updated by  Shihan Pietersz 2 months, 3 weeks ago.

  • Author
    Posts
  • #80042

    Shihan Pietersz
    Participant

    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")
    $service

    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)
    $service
    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 ?

    TIA
    Regards
    Shihan

  • #80045

    Deep
    Participant

    Could you check this command

    Get-Service -ComputerName $serverName -Name "SepMasterService"

  • #80369

    Shihan Pietersz
    Participant

    Thanks Mate.
    Got it working. I used DisplayName instead

    [String]$displayName = "Symantec Endpoint Protection",
    [String]$Status = "Stopped"
    $Service = (Get-service -DisplayName $displayName)
    $Service.WaitForStatus("Stopped",'00:00:30')

    Cheers
    Shihan

You must be logged in to reply to this topic.