Powershell invoke-command access is denied error - not a double hop
Asked Answered
F

2

6

I am building a new network with Server 2016 and a handful of Windows 10 clients. I have run Enable-PSRemoting successfully on all the clients. From the server I run:

Invoke-Command -ComputerName $computer -Scriptblock {'test'}

which results in [computer] Connecting to remote server failed with the following error message : Access is denied. + CategoryInfo: OpenError: (computer:string) [], PSRemotingTransportException + FullyQualifiedErrorId: AccessDenied,PSSessionStateBroken

Because I am only having the remote computer process a string I believe this is not related to the common double hop issue I see in the forums.

I can also run WinRM successfully on the client machines:

Test-WSMan $computer

If anyone has insight into other causes of the access denied error I would greatly appreciate some ideas on where to look.

Thanks.

Freehanded answered 19/10, 2017 at 13:21 Comment(0)
M
5

I guess it is a permission problem. Try to create PsSession object via

$s = New-PSSession -ComputerName "you_computer_name" -Credential(Get-Credential)

Call Invoke-Command with the beforehand created session object:

Invoke-Command -Session $s -ScriptBlock { Get-Service }

This should return a list of all services of remote machine.

Hope that helps.

Meshuga answered 19/10, 2017 at 13:32 Comment(1)
Thanks - this helped me find the issue. I tried logging in with different user accounts and found one that had permission to run invoke-command. I was trying to use an account without full permissions.Freehanded
H
8

You need to be in Remote management users group on target machine (if it's local account). This will be enough for Invoke-Command access

Howey answered 5/11, 2020 at 6:7 Comment(0)
M
5

I guess it is a permission problem. Try to create PsSession object via

$s = New-PSSession -ComputerName "you_computer_name" -Credential(Get-Credential)

Call Invoke-Command with the beforehand created session object:

Invoke-Command -Session $s -ScriptBlock { Get-Service }

This should return a list of all services of remote machine.

Hope that helps.

Meshuga answered 19/10, 2017 at 13:32 Comment(1)
Thanks - this helped me find the issue. I tried logging in with different user accounts and found one that had permission to run invoke-command. I was trying to use an account without full permissions.Freehanded

© 2022 - 2024 — McMap. All rights reserved.