Remote PWSH Session with PSEXEC64

You have installed PWSH (PS7) and have the path. You try to ‘enter-pssession’ and that’s when discover a remote session with PWSH shell will not work without being set native on the server operating system. But you can always use a remote PWSH session using PSEXEC64.

'Call-RDP-PWSH.ps1'
#Uses PSWEXEC64 to open a limited but interactive remote PowerShell 7 window

#Set location
Set-Location d:\powershell

$ServerToRDPTo = Read-Host -Prompt "What server to RDP to?"

# Optional: Set default shell title
$Host.UI.RawUI.WindowTitle = "Connected to $env:computername via pwsh..."

# Start remote PWSH shell with PSEXEC64
#PSEXEC64.exe must be in the path .\pstools
.\pstools\psexec64.exe \\$ServerToRDPTo -h c:\powershell\pwsh.exe -NoExit
<#
#If this fails run this on the server:
New-NetFirewallRule -Name "WinRM HTTP" -DisplayName "WinRM HTTP" -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 5985
#>


Posted

in

, ,

by

Tags: