get-service
1 TopicGet-Service fails but Invoke-Command {Get-Service} succeeds
I'm trying to run a series of PowerShell commands on my desktop computer that connect to one of the corporate servers and checks on the status of the services there. I'm doing a Run As on the PowerShell ISE and sign on using an account that is in the Administrators group of the remote server. This command fails: Get-Service -ComputerName SRV-TSTD123 -DisplayName *Dynamic* Microsoft.PowerShell.Management\Get-Service : Cannot open Service Control Manager on computer 'SRV-TSTD123'. This operation might require other privileges. At line:1 char:1 + Microsoft.PowerShell.Management\Get-Service -ComputerName SRV-TSTD123 ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-Service], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand What's super weird is that this command works: invoke-command -computername srv-tstd123 -scriptblock {powershell Get-Service -DisplayName *Dynamic* } Status Name DisplayName ------ ---- ----------- Running DynGP18eConnect eConnect for Microsoft Dynamics GP ... Running DynGPWebService Microsoft Dynamics GP Service Host Stopped eConnect_Incomi... eConnect Incoming Service for Micro... Stopped econnect_outgoi... eConnect Outgoing Service for Micro... Running PostMasterService Post Master Enterprise for Dynamics GP This command is part of a script supplied by a third party so I'd prefer to solve the root cause of this inconsistent behaviour rather than make a dozen changes to the script. Any idea why the behaviour is so inconsistent? KenSolved1.2KViews0likes4Comments