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

Welcome Forums General PowerShell Q&A Help with script cmdlet (get-service) on remote computer

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 2 months ago.

  • Author
    Posts
  • #80042

    Participant
    Points: 1
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    Could you check this command

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

  • #80369

    Participant
    Points: 1
    Rank: Member

    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

The topic ‘Help with script cmdlet (get-service) on remote computer’ is closed to new replies.