Windows 10 non-server edition Remote Shell
There a are two computers connected to the local network managed under organization domain.
There are simple task list must be implemented on any machine. I want to abstract away that machine list to a script that can be executed simultaneously on any machine.
Now, I am trying to get interactive admin remote shell. Like SSH on linux machines.
Any machine can ping second one.
Any machine has latest PowerShell deployed.
Any machine configured via
winrm quickconfig
Enable-PSRemoting
Let's expose one machine and call it 'admin pc'.
Also let's expose one random non-admin pc.
Next command successfully executed at admin pc.
Enter-PSSession -ComputerName some_name -Credential domain\name
and I got interactive connection.
On that page noted necessary for me parameter to get admin shell, -RunAsAdministrator
, but it doesn't work.
Enter-PSSession -ComputerName some_name -Credential domain\name -RunAsAdministrator
Enter-PSSession : Не удается разрешить набор параметров с использованием указанных именованных параметров.
строка:1 знак:1
+ Enter-PSSession -ComputerName some_name -Credential domain\nam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Enter-PSSession], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.EnterPSSessionCommand
What can cause the error?
To get an elevated admin session on the remote computer you don't need to use -RunAsAdministrator
, just connect with a user that is an administrator on the remote machine. The remote session is already elevated.
The -RunAsAdministrator
switch can only be used together with the -ContainerId
parameter when connecting to a container not when connecting to a remote session.