Skip to content

Instantly share code, notes, and snippets.

@cmcginty
Last active March 26, 2024 16:16
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save cmcginty/f1e559e16305bdd667f6 to your computer and use it in GitHub Desktop.
Save cmcginty/f1e559e16305bdd667f6 to your computer and use it in GitHub Desktop.
Windows Powershell Remoting into Non-Domain Joined System

Powershell Remoting to a Non-Domain Host

  1. From an admin shell, enable PS remoting on the machine you wish to access:
New-ItemProperty -Name LocalAccountTokenFilterPolicy `
  -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System `
  -PropertyType DWord -Value 1

Enable-PsRemoting -Force
  1. From an admin shell, configure your client system to allow remote connections to non-domain machines
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force
  1. Connect to the remote machine using the exact login credentials. For example, a local user would provide SERVER\username and password.
$SERVER = 'REMOTE_SERVER'
$USER   = 'REMOTE_USER'
Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds' ConsolePrompting $true
Invoke-Command -Computer $SERVER -Credential (get-credential "$SERVER\$USER") { ls C:\ }
@basezen
Copy link

basezen commented May 29, 2018

There is a backquote missing on 2nd line, but great, thanks. BTW if the Set-Item call fails, it means remote WS Management on localhost has not been correctly configured, e.g. winrm quickconfig

@lyoungstratus
Copy link

Thanks this was immensely helpful.

@cmcginty
Copy link
Author

@basezen thanks, I fixed the line
@lyoungstratus you're welcome

@jszabo98
Copy link

jszabo98 commented Aug 18, 2022

I didn't need ConsolePrompting set. Is #1 risky?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment