Add a PowerShell Remote Session in Windows Terminal



To get started, we need to open up the settings of the Windows Terminal. This will open up a settings.json file, which you can edit in your favorite editor, for example, Visual Studio Code. To add new “menu items,” you will need to add a profile to the profiles array in the JSON file. In my case, I will add two to different menu items, once I am going to do a PowerShell remoting session to an Azure VM using Windows PowerShell and in the other, I am going to use PowerShell 7.

Windows Terminal Settings profiles


You can see here the following to profile entries:


Remote Session using Windows PowerShell 5.1

{ "name":  "PS Thomas AzureVM", 
"tabTitle": "PS Thomas Maurer AzureVM", 
"commandline": "powershell.exe -NoProfile -NoExit -Command Enter-PSSession -ComputerName azurevmps.westeurope.cloudapp.azure.com -Credential thomas", 
"icon": "C:/Users/thoma/Downloads/AzureVMIcon32.png" 
},


Remote Session using PowerShell 7

{ "name":  "PS Thomas AzureVM", 
"tabTitle": "PS Thomas Maurer AzureVM", 
"commandline": "pwsh.exe -NoProfile -NoExit -Command Enter-PSSession -ComputerName azurevmps.westeurope.cloudapp.azure.com -Credential thomas", 
"icon": "C:/Users/thoma/Downloads/AzureVMIcon32.png" 
},

As you can see, we define the profile name and the tab title in for the Windows Terminal entry. We have the command line command here, which starts the PowerShell remoting session. The command opens a PowerShell session to a specific computer or server using the ComputerName parameter and the Credential parameter for the credentials. In my case, I am connecting to an Azure VM with the name azurevmps.westeurope.cloudapp.azure.com (could also be an IP address) and the username Thomas. The last thing I add is a small icon (32×32 pixel) since I am connecting to an Azure VM, I took the Azure VM icon.


In this scenario, I am using PowerShell Remoting over HTTP, you can use the same thing for your connections using PowerShell Remoting over HTTPS or even PowerShell Remoting over SSH which are way more secure, and should be used for your connections. If you are looking to create the same Windows


Now your Windows Terminal drop-down menu will look like this:

Add a PowerShell Remote Session in Windows Terminal Tab


By selecting one of these profiles, you will automatically open a PowerShell remoting session to a specific computer or server in Windows Terminal.



Windows Terminal – Azure virtual machine VM PS Remote Session


I hope this gives you an idea of how you can add a PowerShell remote session in Windows Terminal menu. If you want to know more about the Windows Terminal, check out the following blog, and if you have any questions, please feel free to leave a comment.


Source: Thomas maurer


0 comments