Share via

Powershell

Anonymous
2023-01-24T14:52:22+00:00

Hi guys

I am training on Powershell and when I try to remote I get the following problem

PS C:\Users\rahimm1> get-service -ComputerName win2klab7862
get-service : Cannot open Service Control Manager on computer 'win2klab7862'. This operation might require other
privileges.
At line:1 char:1

  • get-service -ComputerName win2klab7862
  •     + CategoryInfo          : NotSpecified: (:) [Get-Service], InvalidOperationException  
        + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetServiceCommand  
    
    

Im at a complete loss any ideas anyone

Windows for home | Windows 10 | Settings

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-01-25T03:43:23+00:00

    From what I understand, the -ComputerName was previously removed which includes its usage with get-service and in the following link its stated what you can do instead: https://learn.microsoft.com/en-us/powershell/scripting/samples/managing-services?view=powershell-7.3#getting-remote-services See the note after the words that make it look like its available. That's not put in there well lol.

    Invoke-Command -ComputerName Server02 -ScriptBlock { Get-Service }
    
    You can also manage services with the other *-Service cmdlets. For more information on PowerShell remoting, see about_Remote.
    

    https://learn.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Core/about/about_Remote?view=powershell-7.3

    I'm not really surprised you don't understand as the error was programming based. You need to get used to seeing that and understanding it (to an extent). But, when it comes to command line its normal to be able to go find documentation such as get-service https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-service?view=powershell-7.3 and it will show how to use things. In this case it was PowerShell documentation. If you have a problem, look up the documentation :)

    For the programming aspect "InvalidOperationException" says its not valid. So you know it doesn't like what you put there.

    Was this answer helpful?

    0 comments No comments