PowerShell Remoting From macOS To Windows Server
In our shop, we run the always-excellent PDQ Deploy from Admin Arsenal. However, I wanted a way to control the PDQ console using the command line on my day-to-day workstation, which is a Mac.
To do this, as it turns out, only requires working through some decent (slightly incomplete) documentation online. Amazingly, it's possible!
- PowerShell Core for MacOS
- PowerShell Core installed on the Windows server
- The Win32 OpenSSH build installed on the Windows server
First, you'll need to configure the Windows server or workstation to allow incoming SSH connections via Powershell.
Begin by installing the latest stable .msi of PowerShell Core from the GitHub repo for your build of Windows.
Once that's installed, you'll need to install Win32 OpenSSH. Download the .zip here.
Extract contents of the latest build to
In an elevated (Administrator) PowerShell window, run the following:
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1, where
install-sshd.ps1is the installer file located in the newly extracted directory.
In the same elevated PowerShell window, open the firewall for sshd.exe to allow inbound SSH connections:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
Note: New-NetFirewallRule is for Windows 2012 and above servers only. If you're on a client desktop machine (like Windows 10) or Windows 2008 R2 and below, try:
netsh advfirewall firewall add rule name=sshd dir=in action=allow protocol=TCP localport=22
Start sshd (this will automatically generate host keys under %programdata%\ssh if they don't already exist)
net start sshd
ssh-agentto auto-start (optional)
Set-Service sshd -StartupType Automatic
Set-Service ssh-agent -StartupType Automatic
Then you need to edit the sshd_config file at
%ProgramData%\ssh\. Add a PowerShell subsystem entry as follows:
Subsystem powershell c:/program files/powershell/6.0.2/pwsh.exe -sshs -NoLogo -NoProfile
Restart the sshd service:
Add the path where OpenSSH is installed to your PATH environment variable. The path should be something like:
Next, you'll need to install PowerShell Core on the Mac you want to connect with.
Simply install the .pkg file for the stable build from the same GitHub repo.
Then, let's connect:
- Start PowerShell in your terminal by typing
- Enter a new PSSession remotely by typing:
Enter-PSSession -HostName [server name] -UserName Domain\User -SSHTransport
And that's it! You should now be able to remotely execute PowerShell.