2

I'm trying to get the services on a remote server. When I run the command:

get-service -ComputerName server

I get the following error:

get-service : Cannot open Service Control Manager on computer 'server'. This operation might require other privileges.
At line:1 char:1
+ get-service -computerName server
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-Service], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand

But when I run the command via Invoke-Command it does work:

Invoke-Command -computerName server -ScriptBlock {get-service}

Now I guess there isn't a real difference between the two methods, but I'm wondering why this is. I also think the first option is "cleaner".

I did run Enable-PSRemoting

Anyone knows whats going on?

Quint van Dijk
  • 303
  • 2
  • 12

0 Answers0