PSScriptPad
Last updated
Last updated
PSScriptPad is a tiny editor for Windows PowerShell and PowerShell 7. It requires no installation or configuration and weighs in around 6MB. It can edit, execute and debug PowerShell scripts, design Windows Forms, WPF Windows and package executables.
You can download PSScriptPad from our website. It is a single standalone portable .exe file.
PSScriptPad allows you to select the PowerShell version. The dropdown on the top of the window can be used to select the PS version.
The integrated version uses the PowerShell host within PSScriptPad rather than starting an external PowerShell process.
PSScriptPad supports editing PowerShell scripts. It supports syntax highlighting, syntax checking, IntelliSense and code folding.
Click the New File button on the toolbar to create a new file.
Click the Open button on the toolbar to open a script file.
IntelliSense is automatically invoked. It will complete PowerShell cmdlet names, variables, paths, and parameter names. You can also press Ctrl+Space
to manually invoke IntelliSense. As you type, the IntelliSense list will be filtered. Pressing tab will select and insert the current option.
Code Folding collapses blocks of PowerShell script that you wish to hide. You can collapse blocks such as if blocks, script blocks and functions blocks. Just click the minus and plus sign to close and open blocks.
PSScriptPad will show PSScriptAnalyzer warnings if it is installed. You can customize your PSScriptAnalyzer settings by placing a configuration file in $Env:AppData\PowerShell Pro Tools\PSScriptAnalyzerSettings.psd1
.
PSScriptPad can also debug PowerShell scripts. It supports executing scripts, setting breakpoints, stepping through scripts and viewing the output of scripts in the terminal window.
You can set breakpoints by clicking in the editor margin or by using the F9
button to toggle a breakpoint on the selected line.
You can run a script by clicking the Run button or by pressing F5
. It will run the currently open tab.
You can single step through a script using the following keys:
F10
- Step over
F11
- Step Into
Shift+F11
- Step Out
PSScriptPad can package scripts to executables using package.psd1 files or by selecting a PS1 file and packaging with the default settings.
You can select a PS1 file and click the Package button and the script will be packaged into an executable. The results of the packaging process will be shown within the console.
Package.psd1 files allow you to configure all the settings for the packaging process. You can create a package.psd1 file and then when you click the Package button, it will use that file for configuration.
The Windows Form Designer allows you to create forms with PowerShell scripts.
You can create a new form by clicking the dropdown arrow next to the New button and then click New Windows Form.
You can add controls to a form by expanding the toolbox pane, clicking the control you'd like to add and then clicking on the form. This action requires 2 clicks. In other words, you cannot drag and drop the control from the Toolbox onto the form.
You can set the properties of a control by selecting the control and then modifying properties in the Properties pane.
You can set event handlers for a control by selecting the control, clicking the lightning bolt icon in the Properties pane and then typing the name of the event handler for the event you'd like to hook up. After saving the form, you can view the code-behind file to define what happens when the event takes place.
You can run a form by opening the PS1 file for your form and pressing F5
or by clicking the Run button.
The Scratch Pad is a way of quickly testing scripts. Open the Scratch Pad by clicking the Open Scratch Pad button on the toolbar. The Scratch Pad will save automatically, and you can execute scripts immediately.
Scratches are saved and visible in the Scratches window. Scratches contain the scratch that was executed and the output that was generated from the scratch.
The WPF designer allows you to visually create WPF forms. You can use the inline editor to adjust properties of the form and see it update in real time. You can then use the XAML in your PowerShell scripts.
Click the New WPF Form button to create a new WPF form. It will open the WPF designer.
You can use the inline XAML editor to adjust properties of controls and add new ones. For example, you can add a button to your form by including the following XAML.
You can use the Property window to set properties of a control. To do so, select the control you'd like to modify and then set the specified property in the Property window. The designer and XAML will update after you press Enter
.
Depending on the PowerShell host, you may need to load the WPF framework.
XAML can be loaded directly with PowerShell using WPF classes. To load a WPF form from XAML, you can use the Import-Xaml
function below.
To show the form, you can load the XAML, store the result in a variable and then call ShowDialog
.
You can configure event handlers by selecting the controls and then add script blocks to the events. You will need to ensure that you have names provided for your controls. For example, the XAML below defines a button with the name Button
.
To select the button in PowerShell, you can use the Window's FindName
method.
To set an event handler, like a button click, you can then use add_Click
on the button.
Add an Open with PSScriptPad context menu item to Windows Explorer so you can right click on PS1 files and open them in the editor.
Set the font size for the terminal and code editor windows.
Set the execution policy for PSScriptPad to Bypass.
You can switch between dark and light themes using the options dialog.
Keyboard Shortcuts | Action | Used In |
Ctrl+S | Save | Script, Form Designers |
F5 | Start Debugging or Continue | Script |
F8 | Execute Selection | Script |
F9 | Toggle Breakpoint | Script |
F10 | Step Over | Script |
F11 | Step Into | Script |
Shift+F11 | Step Out | Script |
Ctrl+F | Find | Script, Console |
F3 | Find Next | Script, Console |
Shift+F3 | Find Previous | Script, Console |
Ctrl+C | Copy | Script, Console |
Ctrl+X | Cut | Script, Console |
Ctrl+V | Paste | Script, Console |
Ctrl+H | Replace | Script, Console |
Ctrl+Z | Undo | Script, Console |
Ctrl+Y | Redo | Script, Console |
Ctrl++ | Zoom In | Script, Console |
Ctrl+- | Zoom Out | Script, Console |