- How to change the PowerShell prompt - Wed, Mar 22 2023
- Trim characters from strings in PowerShell - Tue, Mar 14 2023
- Set Chrome, Firefox and Edge as default mail client (mailto handlers) - Mon, Mar 6 2023
To edit a file on a remote computer, you will usually navigate to a network share and load the text into a local editor. Alternatively, you connect via Remote Desktop Protocol (RDP) and use an editor residing on the remote machine.
Interesting option for Nano Server
In some cases, these ways are cumbersome or not even possible, for instance, if you have to edit files on a Nano Server. Microsoft's GUI-less operating system doesn't accept remote desktop connections. At least you could access the server's file system through an admin share.
However, PowerShell ISE offers a comfortable alternative with PSEdit. If you are working on a script, you don't have to leave your development environment to edit the file on a remote server.
Starting a remote session via GUI
First, you have to open a remote session on the server, which you could do the usual way with the corresponding cmdlets.
However, it is easier just to click New Remote PowerShell Tab in ISE's File menu. A dialog will then open where you just have to enter the computer name of the remote machine and your credentials.
Afterwards, you are in the context of the remote computer where you can navigate through the file system with Set-Location and Get-ChildItem. Once you locate your file, you can open it with PSEdit, which also accepts wildcards:
PSEdit .\*.ps1
This command would load all PowerShell scripts from the current directory and open each file in a different tab.
Subscribe to 4sysops newsletter!
The feature is unavailable on older Windows versions. However, if you upgrade to PowerShell 5.1, you will also get the latest PowerShell ISE version.
I would like to point out that you can also open a new PS tab in PSEdit then run:
This will make the connection with currently logged in user, then you can run the PSEdit .\filename.extension
This will also open it in the Editor. Less menu hunting this way. Depending on your setup/work flow I believe both are valid.
You can start the ise from the command line by typing “ise”.