Use the following steps to create and run a script in the Script Pane.

You can open and edit a file type in the Script Pane. Specific file types of interest in Windows PowerShell are script files (.ps1), script data files (.psd1), and script module files (.psm1). These file types are syntax colored in the Script Pane editor. Other common file types you may open in the Script Pane are configuration files (.ps1xml), XML files, and text files.

Note:

The Windows PowerShell execution policy determines whether you can run scripts and load Windows PowerShell profiles and configuration files. The default execution policy, Restricted, prevents all scripts from running, and prevents loading profiles. To change the execution policy to allow profiles to load and be used, see about_Signing and Set-ExecutionPolicy

To create a new script file

On the toolbar, click New , or on the File menu, click New. The created file appears in a new tab. By default a file of type script (.ps1) is created, but it can be saved with a new name and extension. Multiple script files can be created in the same PowerShell tab.

To open an existing script

On the toolbar, click Open…, or on the File menu, click Open. In the Open dialog box, select the file you want to open. The opened file appears in a new tab.

To display the file path

On the file tab, point to the file name. The fully qualified path to the script file appears in a tooltip.

To run a script

On the toolbar, click Run Script, or on the File menu, click Run.

To run a portion of a script

  1. In the Script Pane, select a portion of a script.

  2. On the File menu, click Run Selection, or on the toolbar, click Run Selection.

To stop a running script

On the toolbar, click Stop Execution, press CTRL+BREAK, or on the File menu, click Stop Execution. Pressing CTRL+C also works unless some text has been selected, in which case it maps to the copy function for the selected text.

See Also




Table Of Contents