| description | Example showing how to use Microsoft.OpenSSH.SSHD/Windows to configure the default shell for SSH sessions. |
|---|---|
| ms.date | 07/15/2025 |
| ms.topic | reference |
| title | Configure default shell for SSH |
This example demonstrates how to use the Microsoft.OpenSSH.SSHD/Windows resource to
set the default shell for SSH connections. The examples below configure PowerShell
as the default shell for all SSH sessions.
Note
You should run this example in an elevated context (as Administrator) to ensure the SSH server configuration can be updated successfully.
The following snippet shows how you can use the resource with the dsc resource test command to check whether PowerShell is set as the default shell.
$instance = @{
shell = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'
} | ConvertTo-Json
dsc resource test --resource Microsoft.OpenSSH.SSHD/Windows --input $instanceWhen PowerShell is not set as the default shell, DSC returns the following result:
desiredState:
shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
actualState: {}
inDesiredState: false
differingProperties:
- shellTo set PowerShell as the default shell for SSH, use the dsc resource set command.
dsc resource set --resource Microsoft.OpenSSH.SSHD/Windows --input $instanceWhen the resource updates the default shell, DSC returns the following result:
beforeState: {}
afterState:
shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
changedProperties:
- shellYou can test the instance again to confirm that PowerShell is now the default shell:
dsc resource test --resource Microsoft.OpenSSH.SSHD/Windows --input $instancedesiredState:
shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
actualState:
shell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
inDesiredState: true
differingProperties: []To restore your system to its original state, use the following command to delete the registry key:
$params = @{
Path = 'HKLM:\SOFTWARE\OpenSSH'
Name = 'DefaultShell'
}
Remove-ItemProperty @paramsTo verify the configuration is removed, use the dsc resource get command:
dsc resource get --resource Microsoft.OpenSSH.SSHD/Windows --input $instanceactualState: {}