Latest posts by Wolfgang Sommergut (see all)
- Create, sort and filter CSV files in PowerShell - Tue, Sep 5 2017
- PSEdit - Edit files remotely with PowerShell - Fri, Sep 1 2017
- No future for Windows PowerShell—change to PowerShell Core - Tue, Aug 29 2017
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:
This command would load all PowerShell scripts from the current directory and open each file in a different tab.
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.