PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

1Contents
1.

Welcome to PowerShell Studio

6

2.

Introduction

7

About PowerShell Studio .................................................................................................... 7
How to Buy PowerShell Studio ........................................................................................... 7

3.

Getting Started

9

Installing PowerShell Studio ............................................................................................... 9
Staying Up-to-date ............................................................................................................. 15
Getting Help ....................................................................................................................... 15

4.

Basic Orientation

18

User Interface ..................................................................................................................... 18
The Start Page ............................................................................................................. 19
The Ribbon ................................................................................................................. 20
Quick Access Toolbar .................................................................................................. 24
Panels and Docking .................................................................................................... 24
Status Bar .................................................................................................................... 29
Customizing Your Workspace ........................................................................................... 31
Selecting a Style .......................................................................................................... 31
Customizing the Quick Access Toolbar ...................................................................... 31
Panels and Layouts ..................................................................................................... 32
Introduction to Panels ........................................................................................................................ 32
Working with Panels ........................................................................................................................... 35
Layouts .................................................................................................................................................. 44

5.

Script Editor

48

Editing Aids ........................................................................................................................ 48
Line Numbering and Visual Features ........................................................................ 48
Code Folding ............................................................................................................... 49
Reference Highlighting ............................................................................................... 52
Syntax Checking .......................................................................................................... 53
Navigation and Bookmarks ............................................................................................... 54
Navigation Bar ............................................................................................................ 56
Clipboard Integration ........................................................................................................ 61
Find and Replace Options ................................................................................................. 62
Find and Replace ........................................................................................................ 62
Find in Files ................................................................................................................. 64
Find All References ..................................................................................................... 68

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

2Contents
PrimalSense™ ..................................................................................................................... 70
Converting Cmdlets and Aliases ....................................................................................... 77
Snippets .............................................................................................................................. 80
Script Signing ...................................................................................................................... 83
File Encoding ...................................................................................................................... 85
Context Menu Options ...................................................................................................... 85
Functions and Parameters ................................................................................................ 87
Function Builder ......................................................................................................... 87
Function (Cmdlet) Name ..................................................................................................................... 90
Synopsis and Description .................................................................................................................... 90
Cmdlet Binding ..................................................................................................................................... 90
Output Type ......................................................................................................................................... 91
Parameter Sets ..................................................................................................................................... 92
Default Parameter Set ......................................................................................................................... 93
Parameters ........................................................................................................................................... 93
Parameter Set Filter ............................................................................................................................ 97
Parameter Editor ................................................................................................................................. 99
Special Considerations ...................................................................................................................... 104

Create Functions from Selection ............................................................................. 105
Editing Functions ...................................................................................................... 106
Importing Functions ................................................................................................. 108
Parameter Builder .................................................................................................... 110
Comment-Based Help ...................................................................................................... 112
Comment-Based Help Templates ............................................................................ 116
About the Comment-Based Help Template ................................................................................... 116
Comment-Based Help Template Variables ..................................................................................... 117
Creating a Comment-Based Help Template ................................................................................... 118
Selecting an Existing Comment-Based Help Template .................................................................. 119
Multi-line or Single-line Comments ................................................................................................ 120

File Type Templates ......................................................................................................... 121
Using Predefined File Templates ............................................................................. 121
Creating New File Templates ................................................................................... 124
Template Variables .................................................................................................. 128
Rename Refactoring ........................................................................................................ 130
Verifying Your Script ........................................................................................................ 135

6.

Running and Debugging Scripts

137

Run and Debug Ribbon Controls .................................................................................... 137
Running Scripts ................................................................................................................ 143
Debugging Scripts ............................................................................................................ 144
Working with Breakpoints ....................................................................................... 144

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

3

Contents
Working with Tracepoints ........................................................................................ 146
Passing Parameters .................................................................................................. 149
Debug Panels ............................................................................................................ 150
Running and Debugging Remotely ................................................................................. 150

7.

GUI Designer

154

Forms Designer Introduction .......................................................................................... 154
Creating a New Form ....................................................................................................... 158
Working with Form Controls .......................................................................................... 161
Preview GUI ..................................................................................................................... 167
Adding Events .................................................................................................................. 168
Form Templates ............................................................................................................... 173
Using Predefined Form Templates .......................................................................... 173
Creating New Form or Grid Templates ................................................................... 176
Working with Grid Templates .................................................................................. 180
Exporting Form Scripts .................................................................................................... 183
Initializing GUI Controls .................................................................................................. 184
Control Helper Functions ................................................................................................ 186
Property Sets .................................................................................................................... 190
Control Sets ...................................................................................................................... 195

8.

Panels206

Call Stack Panel ................................................................................................................ 208
Console Panel .................................................................................................................. 208
Debug Console ................................................................................................................. 210
File Browser ..................................................................................................................... 211
Find Results Panel ........................................................................................................... 213
Function Explorer Panel .................................................................................................. 215
Help Panel ........................................................................................................................ 217
Object Browser ................................................................................................................ 218
Output Panel ................................................................................................................... 226
Performance Panel .......................................................................................................... 228
Project Panel .................................................................................................................... 230
Project Files and Folders .......................................................................................... 234
Properties Panel .............................................................................................................. 245
Snippets Panel ................................................................................................................. 250
Toolbox Panel .................................................................................................................. 255

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

4Contents
Tools Output Panel ......................................................................................................... 259
Variables Panel ................................................................................................................ 261
Watch Panel ..................................................................................................................... 264

9.

Projects

267

Project Templates ............................................................................................................ 267
Available Project Templates .................................................................................... 267
Creating a Project ..................................................................................................... 270
Collection Project ..................................................................................................... 273
Module Project ......................................................................................................... 276
New Module from Functions ................................................................................... 277
Project Properties ............................................................................................................ 281
Managing Project Files .................................................................................................... 283
Project File Properties ..................................................................................................... 285
Adding Script Parameters to Projects ............................................................................. 286
Running a Project ............................................................................................................ 287
Exporting a Project .......................................................................................................... 288
Form Return Variables .................................................................................................... 289
Projects and Source Control ........................................................................................... 292

10. Packaging Scripts

294

Creating a Script Package ................................................................................................ 294
Setting up the Script Packager ........................................................................................ 295

11. Source Control Integration

305

Universal Version Control ............................................................................................... 305
Microsoft Source Code Control Integration ................................................................... 308

12. ScriptMerge

315

Running ScriptMerge ....................................................................................................... 315
Comparing Files ............................................................................................................... 315
Comparing Folders ........................................................................................................... 318
Comparing Groups ........................................................................................................... 320
Context Menu Options .................................................................................................... 321
Navigating Between Differences ..................................................................................... 322
Reconciling Differences ................................................................................................... 323
Signing Scripts .................................................................................................................. 323

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved5Contents
ScriptMerge Settings ........................................................................................................ 324

13. Snippet Editor

329

14. Options and Settings

335

Accessing the Options ..................................................................................................... 335
General ............................................................................................................................. 335
Backup .............................................................................................................................. 339
Console ............................................................................................................................. 341
Debugger .......................................................................................................................... 344
Designer ........................................................................................................................... 346
Editor ................................................................................................................................ 350
Assemblies ................................................................................................................ 359
Formatting ................................................................................................................ 360
PrimalSense™ ............................................................................................................ 369
Panels ............................................................................................................................... 371
PowerShell ....................................................................................................................... 374
Source Control ................................................................................................................. 375

15. Remote Script Execution Engine

379

16. Reference

385

SAPIEN Updates ............................................................................................................... 385
Keyboard Shortcuts ......................................................................................................... 388
Appendices ....................................................................................................................... 398
Appendix A: Manual Version ................................................................................... 399
Appendix B: Icon License Attribution ...................................................................... 399

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

6

Welcome to PowerShell Studio1

Welcome to PowerShell Studio

Windows PowerShell scripting and tool-making has never been easier!
Welcome to PowerShell Studio, the premier scripting and tool-making environment
for Windows PowerShell. This single tool will meet all your scripting needs. In addition to creating graphical tools using Windows PowerShell with the GUI designer,
you can also create Windows PowerShell script modules in minutes and easily convert your existing functions to a distributable module.
PowerShell Studio features a robust editor and a script packager with advanced option and platform
selections to help you deliver solutions targeted at specific environments.

About this documentation
This help is designed to show you how to use PowerShell Studio—you can do a quick overview to
get started, work through the topics in detail, and refer back to this guide for additional information
when needed.

Getting started - new users· Download and install PowerShell Studio.
· Get a quick overview of the user interface 18 and see how to customize your workspace 31 .
· Learn how to use PowerShell Studio's powerful script editor 48 , run and debug scripts 137 , and cre-ate GUI forms 154 .
· Visit the support forum to get help from SAPIEN staff and other experienced PowerShell Studiousers.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

7

Introduction
2

Introduction

This section provides an overview of the PowerShell Studio features, shows you how to purchase directly
online or through a reseller, and lets you know how to get answers to your questions.

2.1

About PowerShell StudioPowerShell Studio is the premier Windows PowerShell integrated scripting and tool-making environment.

Key Features· Fully-featured PowerShell Editor.
· Visually create PowerShell GUI tools.
· Convert scripts into executables (.exe) files.
· Create MSI installers.
· Create modules, advanced functions, and windows services.
· For a complete list of current features, visit the PowerShell Studio product page.

What's New
We are always updating and improving PowerShell Studio. You can learn about the latest productupdates on our blog and in the release build log.
· Check out the latest PowerShell Studio tips and product feature demonstrations on the SAPIEN

blog.
· View a brief synopsis of what was changed, added, or fixed in the most recent PowerShell Studiobuild in the product version history.
· Submit feedback and suggestions.

2.2

How to Buy PowerShell Studio

You can buy PowerShell Studio online with all major credit cards. As soon as your transaction completes,
you will be able to download and install 9 the program.
For answers to your pre-order questions, check out the SAPIEN Frequently Asked Questions or post in
the Trial Software / Pre-sales Technical Questions forum.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Introduction

8

Order link and PowerShell Studio product page
Online orders:
https://www.sapien.com/store/powershell-studio

Worldwide authorized resellers:
https://www.sapien.com/company/resellers

PowerShell Studio product page:https://www.sapien.com/software/powershell_studioPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

9

Getting Started
3

Getting Started

This section shows you how to download and install PowerShell Studio, how to keep the application updated with the latest builds, and how to find additional help.

3.1

Installing PowerShell StudioThis section shows you how to install and activate PowerShell Studio, and it also covers how to remove
your activation if you need to use it on a different computer.

Downloading PowerShell Studio
All SAPIEN Technologies software products are downloadable only. Download registered products
from your SAPIEN Account Registered Products page.
Select the 64-bit version of PowerShell Studio to download. The installer software will save to yourdefault download folder (e.g., SPS23Setup_5.8.216_012323_x64.exe).
Starting with the PowerShell Studio 2020 product release, 32-bit versions are no longer available.
Current owners of a license that includes a 32-bit product will have access to that from their SAPIEN
Account Registered Products page.
Want to try before you buy? You can download a trial version here.

Installing PowerShell Studio
Follow these instructions to install PowerShell Studio.
How to install PowerShell Studio
1. In your default download folder, double-click on the downloaded program (e.g.,
SPS23Setup_5.8.216_012323_x64.exe).
2. Reply Yes to the "Do you want to allow this app to make changes to your device?" prompt.
The installation wizard will first check several items, such as available disk space and the presenceof previous builds. If the environment is adequate, the installer will display the legal agreement
which you must accept to proceed:a. Read the terms of the license agreement.
b. Accept the terms of the license agreement. You should never accept license terms unless you
have read them, and you understand them.
c. Once you have accepted the terms, click Install.
The software will install in the default location as shown, unless you change the path.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reservedGetting Started

10

3. The installation may take several minutes.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

11

Getting Started

5. When PowerShell Studio successfully completes the installation, click Finish.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

12

Getting Started

Silent Installation
Use this command if you need to install silently: SPSxxSetup_x.x.xxx_xxxxxx_x64.exe /exenoui /qn(e.g., SPS23Setup_5.8.216_012323_x64.exe /exenoui /qn)
Troubleshooting Installation
If you encounter any problems installing PowerShell Studio please report them in the Installation Issues support forum.
Use these Installer Log parameters to output to a log file: Installer.exe /exenoui /qn /L*v .\SPS_Install.log

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

13

Getting Started
Firewall Considerations
PowerShell Studio can be configured to install a small service to support the Remote Script Execution Engine (RSEE). This will result in a firewall warning as the service attempts to open the port itlistens on. For information on configuring RSEE see Remote Script Execution Engine 379 .
PowerShell Studio occasionally attempts to access a text file located on the sapien.com web site. This
text file contains the version number of the current version of PowerShell Studio—your firewall software may warn you when PowerShell Studio attempts to read this file for the first time. PowerShell
Studio does not transmit any personally-identifiable information when making this check—its sole
purpose is to notify you when updates are available.
PowerShell Studio also accesses the web to activate the product (after initial installation), and to display web pages when you click on web links within the application.

Activating and Deactivating PowerShell Studio
Software activations are outlined in our End-User License Agreement. The number of activations allowed will differ depending on your type of license. For Perpetual Licenses, each licensed user is allowed to have a maximum of two devices activated and operating at any given time for personaluse. For Subscriptions*, each licensed user is allowed to have the software activated on a total of 20
devices with a maximum of two devices operating simultaneously at any given time for personaluse.

Product Activation
Registration is required to activate and operate the product, and also to obtain any customer service
or technical support benefits. Registration only takes a few moments to complete and provides you
with access to special offers including preferred pricing on renewals. You will need an active internet
connection to complete product registration.
An active internet connection may not be required if you have a legitimate reason for needing offline
access. To request offline activation please fill out this request. All requests are considered on a caseby-case basis. Please note: Activation keys belonging to Subscriptions* are not eligible for Offline
Activation.
* Information about software activations for Subscriptions only applies to SAPIEN Technologies
products with a Subscription purchase offer.
To activate PowerShell Studio
The first time you launch a SAPIEN product, the Welcome screen is displayed.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

14

Getting Started

The steps to activate the product vary depending on whether or not you already have a SAPIEN account.
Follow the steps in the Quick Guide to SAPIEN Software Activation to activate the software.
If you are unable to activate the product, contact sales@sapien.com.

Product Deactivation
Removing a software activation, also known as "deactivating", allows you to free up an activation foruse on another device.
You may deactivate your devices to free up your activations at your leisure, but there are certain circumstances where proper deactivation is crucial to prevent the loss of your allotted activations 13 .
Uninstalling the software from your device does not deactivate the activation key.
To deactivate your activation key
In the top-right of PowerShell Studio above the ribbon, click the Activation Information button.

The Activation Information window will open.
Follow the steps in the SAPIEN Software Activation / Deactivation FAQ to deactivate your activation key.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

15

Getting Started

3.2

Staying Up-to-date

We are continually updating PowerShell Studio, both to remove bugs and to add and improve productfeatures. We recommend always staying current with the most recent version to ensure that you are taking advantage of the latest features, functionality, and product stability.
The details for every PowerShell Studio release are available in the version history.

Check for Updates
By default, PowerShell Studio will automatically check for software updates. You can also manuallycheck for updates.
To check for updates· On the Help ribbon > in the Updates section, click Check For Updates to open the SAPIEN Up-

dates 385 tool and see if there is a new PowerShell Studio build available:

3.3

Getting Help

This help manual has been designed to provide all the information you will need for using PowerShell
Studio. In addition to the information in this guide, you can also ask questions in the online support forums 16 .
View PowerShell Studio product feature demonstrations and release details on our blog.

Accessing the help manual· To view the help manual online· In PowerShell Studio, on the Help ribbon > in the Product Support section, click Product

Manual.
The SAPIEN Information Center provides direct access to all of the SAPIEN product manuals.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

16

Getting Started
User forums and support
SAPIEN Technologies provides a variety of ways to get help with PowerShell Studio, including community support forums for your scripting questions.
Support Options
Every registered PowerShell Studio perpetual or subscription license with active maintenance includes basic support in our PowerShell Studio product support forum.
If your PowerShell Studio maintenance has expired, you must renew in order to obtain support.
Premium Support
SAPIEN also offers Premium Support, an elevated support option, at an additional cost. Premium
Support gives you access to our direct technical ticketing system and guarantees a response within
24 hours, as well as personalized attention until the issue is resolved.
Support Forums
SAPIEN provides product support forums where our development team answers user questions.
Our support technicians monitor the forums daily, but response times are not guaranteed.
PowerShell Studio Forums
The Send Feedback menu on the top-right of the ribbon header provides direct links to support options:

The following PowerShell Studio support options are available on the Send Feedback menu:· Report a Problem...

Opens the PowerShell Studio forum where you can report a problem with the software or ask a
product-specific question.
You will need to provide your PowerShell Studio and OS version information 17 to obtain support.
· Provide a Suggestion...

Opens the Feature Request page on the SAPIEN site where you can make a product feature request or suggestion.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

17

Getting Started
Scripting Forums
The following scripting and programming support option is available on the Send Feedback menu:· Scripting Question...

Opens the Scripting Answers forums where you can access community support for answers toyour scripting questions.
Product Version Information
To report a problem in the PowerShell Studio forum, you will need to provide your SAPIEN
product and OS version information.
· Copy Product Information

Copies the product version information to your clipboard.

How to copy version information
To report a problem in the PowerShell Studio forum, you will need to include the product version
and build, and also your OS version and build—and indicate 32 or 64-bit for each.
To copy the required version information
1. On the Send Feedback menu > select Copy Product Information.
2. Paste the version information into your PowerShell Studio forum post.
You can also copy the version information by clicking the About button in the top-right of thePowerShell Studio workspace, and then clicking Copy Version Info:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

18

Basic Orientation
4

Basic Orientation

The PowerShell Studio window has many useful features and can be easily customized for various tasks.
This section explains basic navigation by introducing you to the user interface and showing you how tocustomize your workspace.

4.1

User Interface

This section provides a basic introduction to some of the main PowerShell Studio user interface elements.

PowerShell Studio Program Window
The image below shows the major features of the customizable PowerShell Studio window:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

19

Basic Orientation
4.1.1

The Start Page

When you start PowerShell Studio, the Start Page opens in the center of the window:

Start Page Links·

SAPIEN's Product Support Web Site·

SAPIEN's Scripting Answers Web Forum·

SAPIEN's Web Site·

SAPIEN's Twitter Feed·

SAPIEN's Facebook Page

· Recently Opened Files· Recently Opened Projects· SAPIEN's Blog News Feed

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

20

Basic Orientation
How to disable the Start Page
· Click the Do not show this page on startup link at the bottom-left of the Start Page.

How to enable the Start Page
· Go to File > Options > General > Settings and check Show start page on startup:

4.1.2

The Ribbon

PowerShell Studio displays a ribbon bar at the top of the application window. This topic covers the different ribbon tabs 20 and also the ribbon header buttons 23 located on the right above the ribbon.

Ribbon Tabs
The tabs on the ribbon bar are:
· FileThe File tab contains functions related to opening and closing files and projects, and printing:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

21

Basic Orientation· HomeThe Home tab contains the functions used most often while scripting and is the default tab inPowerShell Studio:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

22

Basic Orientation· Designer

The Designer tab contains functions related to forms manipulation and creation:· Deploy

The Deploy tab contains tools to create packaged executables, MSI installers and deployment procedures:· Tools

The Tools tab contains links to external programs, syntax checking, script signing, compare files
and more:· Source Control

On the Source Control tab you can access restore points, VersionRecall, and other third party
source control commands such as Git:

· Help

The Help tab contains links to product updates, the manual, and online links to the SAPIEN website and support forums:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

23

Basic Orientation· View

The View tab lets you quickly toggle panels open and closed, split the Editor window, change layouts, and more:

Ribbon Header Buttons
There are also four ribbon header buttons on the right above the ribbon bar:

From left to right:·

Minimize the Ribbon (Ctrl+F1) - Only show tab names on the ribbon.

·

Skins - Select color themed skins 23 .

·Activation Information - Display and edit your current activation information.

·

About - Display product information.

Color Themed Skins
The main color theme used by PowerShell Studio can be changed from the Skins button on the topright of the window. There are a variety of color themes to choose from:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

24

Basic Orientation

4.1.3

Quick Access Toolbar

The Quick Access Toolbar on the top-left of the program window provides direct access to frequently
used functions.

Quick Access Toolbar - Buttons

From left to right:·

New (Ctrl+N) - Create a new document.

·

Save (Ctrl+S) - Save the current document.

·

Open (Ctrl+O) - Open an existing document.

·

Execution Policy - Opens the Script Security Center where you can change PowerShell's execution policy.

·

Undo (Ctrl+Z) - Undo the previous modification.

·

Redo (Ctrl+Y) - Redo the last undone modification.

·

Customize - Customize the Quick Access Toolbar.
Click the drop-down arrow to:o Toggle each button to Display or Not Display on the toolbar.
o Show the Quick Access Toolbar below the ribbon.
Add your own frequently used functions to the Quick Access Toolbar.

4.1.4

Panels and Docking

Some PowerShell Studio features have dedicated dockable window panels. You can open, close, dock,and undock the panels, and save your panel arrangements in a layout. This topic introduces the PowerShell Studio panels by showing you how to access the panels, providing a description for each panel,and giving a brief overview on adjusting the panels.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

25

Basic Orientation
Accessing Panels
Some panels appear as a tab in a group of panels. If you move panels around or close a panel andcannot see it, there a number of ways to locate a panel.
To access a panel from the ribbon· On the ribbon, click View > in the Panels group, check or uncheck a panel:

To access a panel using a keyboard shortcut· Execute the associated chorded keyboard shortcut: Press Ctrl+Alt+P, release, then press the cor-

responding character key of the chord.
The panels and their shortcuts are listed in the table below, and are also displayed in the ribbon
tooltip for each panel:

Available Panels
Panels available in PowerShell Studio:

Panel
Call Stack

PowerShell Studio - Help Manual

Keyboard Shortcut

Description

Ctrl + Alt + P, K

Displays the function or procedure callsthat are currently on the stack. Used indebugging.

© 2023 by SAPIEN Technologies Inc., all rights reserved

26

Basic Orientation

ConsoleCtrl + Alt + P, C

Hosts PowerShell and other embedded
consoles in a separate process.

Debug Console

Ctrl + Alt + P, D

A customizable command line console(PowerShell, PSCore, Bash, etc.) that allows you to interact with a debug session
when at a breakpoint.

File Browser

Ctrl + Alt + P, I

Provides direct access to folders and files
on your hard drive.

Find Results

Ctrl + Alt + P, R

Displays Find in Files and Find All References search results.

Function Explorer

Ctrl + Alt + P, F

Lists all functions, events, workflows, andconfigurations referenced in the current
file. When working in a project, functions
defined in other project files are also displayed.

Help

Ctrl + Alt + P, H

Displays Windows PowerShell commandline help and WMI Help (F1).

Object Browser

Ctrl + Alt + P, B

Displays Windows PowerShell modules
and commands, .NET Framework types,
WMI objects, and database objects.

OutputCtrl + Alt + P, O

Displays all script ouptut including general application messages, build information, errors, debug, verbose, and tracepoint output.

Performance

Ctrl + Alt + P, M

Displays the CPU and memory usage ofyour PowerShell scripts.

Project

Ctrl + Alt + P, J

Central location for managing projects,
including the project's files and folders.

Properties

Ctrl + Alt + P, P

View and edit the control properties
when working in the GUI Designer. Edit

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

27

Basic Orientation

project settings and project file settings
when working in a project.
Snippets

Ctrl + Alt + P, S

View and manage preset and userdefined snippets (reusable text and code).

ToolboxCtrl + Alt + P, T

Displays Windows Forms controls andcontrol sets that are available in the GUI
Designer.

Tools Output

Ctrl + Alt + P, L

Displays output from external tools.
When debugging, displays breakpoint
notifications and post mortem messages.

Variables

Ctrl + Alt + P, V

Lists all variables and values in the current
scope during a breakpoint when debugging.

Watch

Ctrl + Alt + P, W

Displays the values of variables and expressions that you define when debugging.

To quickly access a panel, execute the associated chorded keyboard shortcut. Simply press
Ctrl+Alt+P, release, then press the corresponding character key of the chord.
For details about the content of each panel, see Panels.

Working with Panels
Panels can be adjusted by using the buttons at the top-right of the panel:

From left to right·

Maximize / Restore - This option is visible when there is more than one panel in a location.
You can Maximize the panel to full-size in the location, or Restore the panel so that all panels in thelocation are visible.

·

Auto Hide / Dock - Auto Hide will vertically collapse, or "Hide" the panel in the location. Dock
will open the panel to a fixed position in the location.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

28

Basic Orientation·

Close - Remove the panel from the location.

You can left-click on the title bar of a panel and drag it to another location. The docking indicator willappear as soon as you begin to drag the panel:

You can drop the panel onto a docking hint to have it snap to the desired location, or leave thepanel floating in the window. As shown by the blue highlighting in the example below, the Snippets
panel will be docked below the Object Browser:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

29

Basic Orientation

4.1.5

Status Bar

The status bar at the bottom of the PowerShell Studio window displays information about the current
configuration of PowerShell Studio.
The left side of the status bar contains the following:· Font Size Slider

The Font Size Slider is used to increase or decrease the font size used in the PowerShell Studio editor window.
· Layouts

The Layouts menu is used to define and choose different layouts for the scripting environment.
· Auto Layout

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

30

Basic Orientation
The Auto Layout button is used to enable or disable context sensitive layout changes.
To learn more about the layout options, see Layouts 44 .
Indicators
The right-side of the status bar includes the following status indicators:·

Running Script
Appears when a script is running.

·

Refreshing Local Cache
Appears when the local cache is refreshing.

·PowerShell Detected
Appears if PowerShell is detected.

· READ

Read-only status of current file.
· OVR

Overwrite.
· CAP

Caps Lock.
· NUM

Num Lock.
· File Encoding

You can change the encoding of a file by selecting an option from the file encoding menu on thestatus bar: ASCII, UTF-8-BOM, UTF-8, UTF-16 BE, UTF-16 LE.
· Line Terminator

You can change the line terminator by selecting an option from the line termination menu on thestatus bar: Windows (CRLF), Unix (LF).
· LineThe line position of the caret in the current file.
· Col

The column position of the caret in the current line.
· CharThe character position of the caret in the current line.
When a script is running or the local cache is refreshing, the relevant icon appears on the status bar.
To cancel a running process or task, click the appropriate icon and select Stop.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

31

Basic Orientation

4.2

Customizing Your Workspace

The PowerShell Studio workspace can be easily customized to suit your personal preference.

4.2.1

Selecting a Style

A style is a visual layout, skin, or theme.
To change the style for PowerShell Studio· In the upper right corner, click Skins and then select a style:

The default style is Visual Studio 2013 Light.

4.2.2

Customizing the Quick Access Toolbar

The Quick Access Toolbar at the top-left of the PowerShell Studio program window provides access toyour most frequently used tools.
To add buttons to the Quick Access Toolbar· Navigate to the desired function, then right-click and select Add to Quick Access Toolbar.

For example, to add a Keyboard Shortcuts button to the Quick Access Toolbar:o On the Help ribbon, right-click Keyboard Shortcuts > select Add to Quick Access Toolbar.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

32

Basic Orientation

To reset the Quick Access Toolbar· The Quick Access Toolbar can be reset on the Panels tab of the Options dialog (File > Options >Panels or Home > Options > Panels):

4.2.3

Panels and Layouts

Some PowerShell Studio tools are displayed in dockable window panels. This section explains how towork with panels, and how to save your panel arrangements in a layout.

4.2.3.1

Introduction to Panels

You will work with panels in the customizable PowerShell Studio window:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

33

Basic Orientation

You can open, close, dock, and undock panels, and also save your panel arrangements in a layout 44.

Accessing Panels
If you move panels around or close a panel and cannot see it, you can access the panel from the ribbon (View > Panels) or by executing the associated chorded keyboard: Press Ctrl+Alt+P, release,then press the corresponding character key of the chord.
The panels and their chorded keyboard shortcuts are listed in the table below, and also in the Keyboard Shortcuts 398 topic.

Available Panels
Panels available in PowerShell Studio:

Panel
Call Stack

PowerShell Studio - Help Manual

Keyboard Shortcut

Description

Ctrl + Alt + P, K

Displays the function or procedure calls© 2023 by SAPIEN Technologies Inc., all rights reserved

34

Basic Orientationthat are currently on the stack. Used indebugging.
ConsoleCtrl + Alt + P, C

Hosts PowerShell and other embedded
consoles in a separate process.

Debug Console

Ctrl + Alt + P, D

A customizable command line console(PowerShell, PSCore, Bash, etc.) that allows you to interact with a debug session
when at a breakpoint.

File Browser

Ctrl + Alt + P, I

Provides direct access to folders and files
on your hard drive.

Find Results

Ctrl + Alt + P, R

Displays Find in Files and Find All References search results.

Function Explorer

Ctrl + Alt + P, F

Lists all functions, events, workflows, andconfigurations referenced in the current
file. When working in a project, functions
defined in other project files are also displayed.

Help

Ctrl + Alt + P, H

Displays Windows PowerShell commandline help and WMI Help (F1).

Object Browser

Ctrl + Alt + P, B

Displays Windows PowerShell modules
and commands, .NET Framework types,
WMI objects, and database objects.

OutputCtrl + Alt + P, O

Displays all script ouptut including general application messages, build information, errors, debug, verbose, and tracepoint output.

Performance

Ctrl + Alt + P, M

Displays the CPU and memory usage ofyour PowerShell scripts.

Project

Ctrl + Alt + P, J

Central location for managing projects,
including the project's files and folders.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

35

Basic Orientation

Properties

Ctrl + Alt + P, P

View and edit the control properties
when working in the GUI Designer. Edit
project settings and project file settings
when working in a project.

Snippets

Ctrl + Alt + P, S

View and manage preset and userdefined snippets (reusable text and code).

ToolboxCtrl + Alt + P, T

Displays Windows Forms controls andcontrol sets that are available in the GUI
Designer.

Tools Output

Ctrl + Alt + P, L

Displays output from external tools.
When debugging, displays breakpoint
notifications and post mortem messages.

Variables

Ctrl + Alt + P, V

Lists all variables and values in the current
scope during a breakpoint when debugging.

Watch

Ctrl + Alt + P, W

Displays the values of variables and expressions that you define when debugging.

To quickly access a panel, execute the associated chorded keyboard shortcut. Simply press
Ctrl+Alt+P, release, then press the corresponding character key of the chord.
For details about the content of each panel, see Panels.

4.2.3.2

Working with Panels

This section shows how to work with panels by providing an overview of the most common tool paneltasks.

Opening a PanelTo open or re-open a panel· On the ribbon, click View > in the Panels group, check or uncheck a panel.

-OR· Execute the chorded keyboard shortcut 398 for the panel you want to access: Press Ctrl+Alt+P, re-lease, then press the corresponding character key of the chord.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

36

Basic Orientation

Panel Buttons
Once a panel is displayed it can be adjusted by using the buttons at the top-right of the panel:

From left to right·

Maximize / Restore - This option is visible when there is more than one panel in a location.
You can Maximize the panel to full-size in the location, or Restore the panel so that all panels in thelocation are visible.

·

Auto Hide / Dock - Auto Hide will vertically collapse, or "Hide" the panel in the location. Dock
will open the panel to a fixed position in the location.

·

Close - Remove the panel from the location.

Closing a PanelTo close a panel· In the top-right of the panel, click Close:

Showing a Hidden PanelTo show a hidden panel
Hidden panels are open, but are not docked or floating. They open when you click them, stay open
while you use them, and hide when you click away.
To show a hidden panel, at the edge of the window (left, right, or bottom) click the panel tab thatyou want to show:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

37

Basic Orientation

The panel will open and stay open until you click away.
You can see the tabs of hidden panels at the left, right, and bottom edges of the window.
To keep a hidden panel open, dock it.

Docking a Hidden Panel
To dock a hidden panel
This action causes an open, hidden panel to "dock" in a fixed position.
· In the top-right of the panel, click the pin (to "pin" or "dock" the panel):-OR· Right-click the panel title bar and select Dock.

Hiding a Panel
To hide a panel
This action keeps a panel open, and causes it to "hide" when you click away from the panel.
· In the top-right of the panel, click the pin (to "unpin" or "auto hide"):-OR-

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

38

Basic Orientation· Right-click the panel title bar and select Auto Hide.

Floating a Panel
To float a panel
This action releases a panel from a docked position.
1. Right-click the panel title bar (or panel tab if the panel is grouped), and select Float.
2. Avoiding the docking indicator, drag and release the panel in the desired location.
-OR1. Drag the panel title bar (or panel tab if the panel is grouped). If the title bar contains a group ofpanels, dragging the title bar will drag the entire group.
2. Avoiding the docking indicator, release the panel in the desired location.

Re-docking a PanelTo re-dock a panel
This action returns a floating panel to its most recently docked position.
· Right-click the panel title bar and select Dock.

Moving a Panel
To move a panel
You can left-click on the title bar of a panel and drag it to another location. The docking indicator willappear as soon as you begin to drag the panel:

You can drop the panel onto a docking hint to have it snap to the desired location, or leave thePowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

39

Basic Orientation
panel floating in the window. As shown by the blue highlighting in the example below, the Snippets
panel will be docked below the Object Browser:

Another example of how to move a panel:
1. Drag the panel title bar toward the desired location. If the title bar contains a group of panels,
dragging the title bar will move the entire group.
To separate a panel from a group, right-click the panel tab and click Float.
The docking indicator appears. The locations on the docking indicator represent locations in thePowerShell Studio layout:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

40

Basic Orientation

For example, the center position corresponds to the center of the layout, the center-left positionindicates the center-left position of the layout, and the left position indicates the left side of thelayout.
2. Drag the panel to a location on the docking indicator, and then drop it.
As you move the panel toward a position on the docking indicator, the corresponding part ofthe layout displays a blue overlay where the panel will dock:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Basic Orientation

41

When you drop the panel, it occupies the blue space:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

42

Basic Orientation

If you are having trouble dragging a tab or panel, dock it and try again.

Converting a Panel to a Tab
To convert a panel to a tab
You can convert a panel to a tab of the PowerShell Studio Script Editor or Designer window.
· Drag the panel and drop it on the tab bar:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

43

Basic Orientation-OR· Right-click the panel title bar (or panel tab if the panel is grouped), and then click Dock as Tabbed

Document.

Saving a Layout
To save a new layout
A layout defines the position and visibility of the various PowerShell Studio panels.
To save your own custom layout:
1. Arrange the panels to your preferred layout.
2. From the Layouts menu on the status bar, click Layouts > Save Layout.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

44

Basic Orientation

4.2.3.3

Layouts

A layout defines the position and visibility of the various PowerShell Studio panels. PowerShell Studiowill automatically choose a layout based on what you are doing (via context sensitive Auto Layout). You
can also choose from preset layouts, save your own custom layouts, and configure layout options.

Preset Layouts
There are preset layouts available that configure PowerShell Studio for specific activities. To switch toa preset layout, click Layouts on the bottom-left of the status bar and select a layout from the list:· Default Layout

The Default Layout is the same as the Editor layout.
· Console Layout

The Console Layout emphasizes the script editor and console panel.
· Debug Layout

The Debug Layout emphasizes the script editor, watch and output panels.
· Designer Layout

The Designer Layout emphasizes the code editor, toolbox and properties windows. This is ideal fordeveloping PowerShell forms applications.
· Editor Layout

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

45

Basic Orientation
The Editor Layout emphasizes the code editor, project browser, object browser, output window,
function explorer and snippet panels. This is a good general purpose panel layout.
· Editor Only Layout

The Editor Only Layout hides everything except the editor window.

Auto Layout
On the bottom-left of the status bar, to the right of the Layouts menu, is the Auto Layout option
which is used to enable or disable automatic context sensitive layout changes.
To toggle Auto Layout on or off
Click the Auto Layout button:

Custom Layouts
You can save your own customized layout and access it from the Layouts menu on the status bar.
To save a customized layout
Configure the panels in PowerShell Studio to your preferred layout and then click Layouts > Save
Layout:PowerShell Studio will display the Save Layout dialog. Type a File Name for your new layout, thenclick Save:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

46

Basic Orientation

Each layout pertains to a .layout file, which contains the state information of the panels in PowerShell
Studio.
Layout files are saved in the following location: %Users%\<user>\AppData\Roaming\SAPIEN\PowerShell Studio <year>\Layouts
The new layout will appear in the list of available layouts:

To maintain the current layout, disable Auto Layout on the status bar:

Layout Options
Layout options can be configured on the Panels tab of the Options dialog (File > Options > Panels
or Home > Options > Panels):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

47

Basic Orientation

Selecting (Current) for any Auto Layout option will keep the layout that you are currently using.
For example, if the Editor Layout is set to (Current), when you open the script editor a layout change
will not be triggered.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

48

Script Editor
5

Script Editor

PowerShell Studio is much more than just a script editor—it is a complete environment which includes
dozens of built-in tools and functions to make scripting more efficient. At the heart of PowerShell Studio is the industries most powerful and flexible code editor. While it's easy to start using PowerShell Studio's editor without any training, some of its features can be easily overlooked. In this section you willlearn about the script editor features, including tips for using PowerShell Studio more efficiently.

5.1

Editing Aids

PowerShell Studio includes many features that make script editing easier.

5.1.1

Line Numbering and Visual Features

PowerShell Studio uses line numbering and visual cues, such as coloring, to make your script editing
easier.

Line Numbering and Color Status
Line numbers are displayed on the left edge of the editor panel:

The colored bar to the right of the line numbers indicates the edit status of your code:· GreenLines marked with green have been edited and saved since you opened the file.
· YellowLines marked with yellow have been edited but not yet saved.
· No ColorLines without a color have not been edited in this session.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

49

Script Editor
Pair Highlighting
PowerShell Studio also highlights pairs of braces, brackets, and parentheses in grey: { }, [ ], and ( ).
For example, when you click on a bracket its partner will be highlighted:

5.1.2

Code Folding

Code folding is a feature that allows you to collapse or expand sections of your code (regions). Collapsing sections of code in a long script makes it easier to focus on the section you're working on.
PowerShell Studio automatically creates regions, and you can also create your own.

Automatic Regions
PowerShell Studio automatically creates foldable regions from declared functions, multi-line comment blocks, and script blocks:

When collapsed, PowerShell Studio properly displays line numbering, accounting for the lines contained within the collapsed (or folded) region. This ensures that line number-based error messages
and other information remain accurate:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

50

Script Editor

Named Regions
A named region is a region that remains persistent even when the file is opened and closed.
To create a named region
Highlight a block of code, then select Home > Edit > Regions > Create Region (Ctrl+R):

A region is created with the default name 'RegionName', which is highlighted and ready for you toedit:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

51

Script Editor

Named regions are convenient because the name remains visible when folded—indicating what theregion contains:

You can also create a named region manually by specifying the #region and #endregion keywords
on comment lines within your script.

Manipulating Regions
The options for working with outlines and regions are located in Home > Edit > Regions:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

52

Script Editor· Create Region (Ctrl+R)

Creates a persistent folding region.
· Toggle Outline (Ctrl+Shift+M)

Collapses or expands the current outline or region.
· Collapse All (Ctrl+Minus Sign)

Collapses all the expanded outlines and regions.
· Expand All (Ctrl+Plus Sign)

Expands all the collapsed outlines and regions.
· Include (Comments, Functions, Regions, Script Blocks, Strings)

Select which regions collapse and expand when you use the collapse / expand commands.
When you load a script file, the editor will collapse all of the nodes selected under 'Include'. This
option is set by default under Home > Options > Editor > Collapse regions on load.

5.1.3

Reference Highlighting

PowerShell Studio's reference highlighting feature makes it easy to highlight references in your code
simply by double-clicking on a variable, identifier, member, function, or any other object.
Reference highlighting recognizes the different ways variables and parameters are referenced:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

53

Script Editor

You can also use the Ctrl+W(ord) keyboard shortcut to select the current word and highlight thereferences.

5.1.4

Syntax Checking

PowerShell Studio constantly analyzes the code you type. Syntax errors are indicated by a red exclamation point ( ! ) in the margin to the left of the line with the error in the code editor.
Hover over the exclamation point to display a tool tip with information about the error:

You can also manually invoke the syntax checker from the Home tab > Edit section > Analysis menu
> Check Syntax:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

54

Script Editor
5.2

Navigation and Bookmarks

The Navigation section of the Home tab provides options for navigating 54 and bookmarking 55 , enabling you to quickly move between different locations in your scripts:

Navigating· Previouso Previous Function (Ctrl+Shift+F12)
Go to the previous function declaration.
o Previous Change (Ctrl+Shift+Up)
Go to the previous position where you made an edit (i.e., where you typed or deleted something.)o Previous Occurrence (Ctrl+Shift+Alt+Up)
Go to the previous occurrence of the selected item.
· NextPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

55

Script Editoro Next Function (Shift+F12)
Go to the next function declaration.
o Next Change (Ctrl+Shift+Down)
Go to the next position where you made an edit (i.e., where you typed or deleted something.)o Next Occurrence (Ctrl+Shift+Alt+Down)
Go to the next occurrence of the selected item.
· Go To Line (Ctrl+G)

Go to a specific line number.
· Last Edit (Ctrl+E)

Go to the last position where there was a modification.
· Navigate Backward (Ctrl+Shift+Minus Sign)

Navigate backward to the previous location.
· Navigate Forward (Ctrl+Shift+Plus Sign)

Navigate forward to the previous location.

Bookmarking
Use bookmarks in your files to mark locations and navigate between them:

To toggle a bookmark on or off
Position the caret on the line where you want to add or remove a bookmark, or on a line that isalready bookmarked, then select Bookmark > Toggle Bookmark (Ctrl+F2).

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

56

Script Editor

Bookmarks are displayed to the left of the line numbers in the script editor window, as shown below:

To remove all bookmarks in the active document, select Bookmark > Clear All Bookmarks(Ctrl+Shift+F2).
To move between bookmarks
On the Home tab > click Previous Bookmark (Shift+F2) or Next Bookmark (F2) to quickly jump
between bookmarks:

5.2.1

Navigation Bar

Above the editor is a navigation bar which allows you to jump between functions, workflows, events,and more:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

57

Script Editor

Navigation Bar - Options
The navigation bar contains three drop-downs.
From left to right:· Global Scope

Jump to class or enumerator declarations.
· Function

Jump to a specific function, event, workflow, class, or configuration.
· Navigation

Jump to the caret position, last edited position, current debug position, breakpoints, tracepoints,
bookmarks, syntax errors, or comments (#MARK; #TODO).
Global Scope
The Global Scope drop-down lets you jump to class or enumerator declarations contained within the
file:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

58

Script Editor

Function
Use the Function drop-down to jump to a specific function, event, workflow, class, or configuration:

The Function drop-down reflects the context of the caret position as you navigate within the script.
For example, when the caret is within the scope of a class, the Function drop-down reflects the class'member declaration:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

59

Script Editor

Navigation
The Navigation drop-down allows you to jump to specific positions that include the caret position,
the last edited position, current debug position, breakpoints, tracepoints, bookmarks, syntax errors,
and more:

The Navigation drop-drown provides a preview of the line contents in order to help direct you to thecorrect position:

TODO / DONE Task Comments
PowerShell Studio automatically includes TODO comments when you create event handlers for GUI
applications. These comments are reminders that you need to place your custom script in the event
script block:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

60

Script Editor

To mark a TODO comment as complete, right-click on the associated line in the script and selectMark task as DONE:

DONE comments will appear in the Navigation menu with a green check mark as you complete
the tasks.
MARK Comments
Comments starting with #MARK: will display in the Navigation menu:

Use MARK comments to designate navigation points within your script

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

61

Script Editor

5.3

Clipboard Integration

PowerShell Studio provides the following Copy, Cut, and Paste clipboard functionality:· Copy (Ctrl+C)

Copy the selection and put it on the clipboard.
· Copy Encoded

Copy the selection and put it on the clipboard as Base64 encoded text.
· Copy HTML (Ctrl+Shift+C)

Copy the selection and put it on the clipboard as formatted HTML, for pasting into web applications.
· Cut (Ctrl+X)

Cut the selection and put it on the clipboard.
· Paste (Ctrl+V)

Paste the contents of the clipboard.
Use the Copy Encoded option from the Copy pull-down to Base64 encode the selected text andcopy it to the clipboard:

Copy HTML is en easy way to include code in a blog post. Simply select the code in PowerShell
Studio and click Home > Copy HTML on the ribbon (or right-click the selected code in the editor
and select Copy HTML), and then paste the HTML for the code in the Text view of the blog post. The
result is perfectly copied code, including color and formatting.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

62

Script Editor

5.4

Find and Replace Options

PowerShell Studio includes extensive, powerful search and replace features, allowing you to revise a file's
contents quickly and easily.

5.4.1

Find and Replace

This topic explains how to search, and also how to find and replace.

How to use Find/Replace
Basic searching is easily accomplished from Home > in the Edit section, Find Replace (Ctrl+F):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

63

Script Editor
The Find/Replace dialog allows you to specify parameters for your search:

The Find/Replace dialog will stay open while you edit a script.
The Find/Replace dialog options:· Find what

Enter the text you are searching for. Use the drop-down list in the right of the field to accesssearch term history.
· Replace with

The replacement text (optional).
· Match case

Makes the search case sensitive.
· Match whole word

Only finds occurrences of the search text that appear as whole words.
· Search up

Searches upwards from the cursor position.
· Use

Enables special processing of the search text. There are two options available:o Regular expressions
Uses the full power of regular expressions in your search strings.
o Wildcard matching
Uses ? to represent a single character, or * to represent multiple characters.
· Search hidden text

Includes folded code regions in the search.
· Search in selection

Confines the search to a highlighted section of code.
· Find Next

Find the next occurrence of your search string.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

64

Script Editor· Replace

Replace the search string occurrence with the replacement text.
· Replace All

Replace each occurrence of the search string with the replacement text.
· Mark All

Places a bookmark at each location where your search string occurs.
Use F2 and Shift+F2 to move back and forth between bookmarks.
· CloseClose the Find/Replace dialog.
Replace always operates on the entire script regardless of whether any code is highlighted ornot, unless the 'Search in selection' option is checked.
Regular Expression Searching
Checking the Use checkbox in the Find/Replace dialog enables a drop-down list where you can select Regular expressions or Wildcards.
Selecting Regular expressions enables a button to the right of the Find what: field that displays
a quick list of common regular expressions that you can use to quickly add components to yoursearch text:

5.4.2

Find in Files

Find in Files allows you to search multiple files for specific text without having to open each file individually.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

65

Script Editor
How to use Find in Files
You can access the Find in Files tool from the Home tab > Edit section > Find Replace menu > Find
in Files... (Ctrl+Shift+F):

Enter your search criteria in the Find in Files dialog, and then click Find in Files:

The Find in Files dialog options:· Find what

Enter the text you are searching for. Use the drop-down list in the right of the field to accesssearch term history.
o Match caseMake the search case sensitive.
o Match whole word
Find occurrences of the search text that appear as whole words.
· Find In

Designate the search folder by selecting from the drop-down list options. To select a different
folder, use the More Options button (...) to the right of the Find In field.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

66

Script Editoro Current Document
Search in the current document only.
o All Open Documents
Search in all of the open documents.
o Current Project
Search in all of the project files.
· Search in subfolders

Checked to search the subfolders recursively. If unchecked, the root directory will be searched.
· File Types

Specify the file types to be searched. By default, all PowerShell Studio file types are included.

· Use

Enables special processing of the search text. There are two options available:o Regular expressions
Uses the full power of regular expressions in your search strings.
o Wildcard matching
Uses ? to represent a single character, or * to represent multiple characters.
Checking the Use checkbox in the Find in Files dialog enables a drop-down list where you can select Regular expressions or Wildcards.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

67

Script Editor
Selecting Regular expressions enables a button to the right of the Find what: field that displays aquick list of common regular expressions that you can use to quickly add components to yoursearch text:

After you select the search options, click the Find in Files button to start the search.
Search Results
The search results will appear in the Find Results 213 panel as the search progresses:

Double-clicking on a search result will open the file at the line specified in the result. Viewed results
are indicated by a green check mark on the left column:

The check mark indicator helps you keep track of all the locations you visited.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

68

Script Editor
To manually mark a result as visited or unvisited, right-click on a result and select Mark as Visited orMark as Unvisited:

5.4.3

Find All References

Find All References builds upon PowerShell Studio's reference highlighting 52 feature. In addition tohighlighting all references of the object in the Editor, the references are also displayed in the Find Results 213 panel.

How to use Find All References
Click on the object, command, property, or method that you want to search for, and then on the ribbon select the Home tab > Edit section > Find Replace menu > Find All References (Ctrl+Alt+F):-ORRight-click on the object / command in the editor and select Find All References (Ctrl+Alt+F):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

69

Script Editor

The references are highlighted in the editor and are also listed in the Find Results panel:

As previously mentioned (Find in Files > Search Results 67 ), the Find Results panel allows you toview specific search results and track visited locations.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

70

Script Editor
If you are working with a project, references located in the other project files will also display in
the Find Results panel.

5.5

PrimalSense™

PrimalSense™ is SAPIEN's brand-name for our powerful, flexible, contextually aware code-hinting andcode-completion feature. PrimalSense is similar in functionality to Microsoft IntelliSense, which is foundin Microsoft's Visual Studio products.

PrimalSense Features
PrimalSense works automatically in most cases and provides the following features:· Syntax Coloring

PrimalSense automatically colors your code syntax to help make literals, statements, comments,and other elements stand out more clearly. By default, PrimalSense doesn't begin working until
you've typed a few characters from a recognized keyword, variable name, or other element.
To trigger immediate PrimalSense help, press Ctrl+Space, or type the first couple of letters ofwhat you are looking for and then press Ctrl+Space. PrimalSense will display a list of intrinsic
keywords, defined functions, cmdlets, variables, etc.
· Case Correction

When appropriate, PrimalSense automatically corrects the case of intrinsic statements, cmdlet
names, variable names, and other elements.
· Variables

PrimalSense automatically attempts to complete variable names, function names, and the namesof other elements to save you from having to type the full names:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

71

Script Editor
This also includes a number of standard PowerShell variables including:o $env - to access the environment variables on your computer:o The scoping operators $Global, $Private and $Script:· Code Completion

Code completion speeds the development process by predicting the rest of the construct as you
are typing. The code editor will offer you choices as you type, thus reducing the amount you needto type and also minimizing the number of syntax errors in your scripts.
· Cmdlet Help

If you hover over any cmdlet or alias in the code editor PowerShell Studio will display a tool tip
containing basic information about the cmdlet. Typing a space after the cmdlet or alias name will
load the appropriate help file into the help panel.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

72

Script Editor· Contextually Aware

PrimalSense provides assistance while you are scripting, and also makes it easy to pick up rightwhere you left off. Simply position the caret at the desired location and press Ctrl+Space to trigger PrimalSense. PrimalSense will list the appropriate items depending on the context:

PrimalSense for parameter attributes:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

73

Script Editor

Property and Method Completion
Type Sense
When working with objects, PrimalSense displays pop-up lists containing available members, suchas methods and properties. In many cases PrimalSense can provide "deep" assistance, helping you
work with sub-objects and their members as well.

PrimalSense also displays a tool tip showing more information about a property or method such as:· Description.
· Parameter details.
· Link to view in the object browser.
· Link to view the online MSDN documentation.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

74

Script Editor
Method Completion
As you type the name of a method, PrimalSense will show you a list of all of the methods that startwith the letters you have typed. If it has identified the correct method, press < Tab > to automatically enter the rest of the name:

Assemblies
When you work with .NET assemblies in your scripts PowerShell Studio can parse them in order tooffer better PrimalSense help. This also ensures that PowerShell uses the underlining types, such as
the form controls.
Use either of these options to load assemblies into PowerShell Studio:· On the Home tab > in the Edit section, click the Assemblies button:

In the Assemblies dialog, use the green + button to load an assembly into the editor, or the red button to remove an assembly:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

75

Script Editor

PowerShell Studio does not list the base .NET assemblies such as mscorlib, system, system.data, etc. As a result, the assembly list will most likely be empty but PowerShell Studio willcontinue to provide PrimalSense for these assemblies without explicitly listing them. This way, only
the external assemblies that you specify will be listed. Note that GUI psf files created with PowerShell Studio 2017 or earlier will still retain the old assemblies list.
-OR· Right-click on a class in the Object Browser:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

76

Script Editor

Choose one of the following options:o Insert
Loads the containing assembly and adds the name of the class into the code editor.
o Assembly Included
Loads or unloads the assembly.
In this example the 'System.DirectoryServices' assembly has been added to PowerShell Studio andPrimalSense is able to offer help about the 'DirectoryEntry' class:

If the assembly is not added to PowerShell Studio, PrimalSense cannot provide any help. In thescreenshot below, PrimalSense cannot offer any help because the 'System.DirectoryServices' assembly has not been loaded.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

77

Script Editor

If an assembly has been removed from a machine, PowerShell Studio will not be able to load it
the next time it starts. The Assemblies dialog indicates this by displaying a yellow triangle with an exclamation ( ! ) point to the left of the assemblies that could not be loaded:

5.6

Converting Cmdlets and Aliases

PowerShell Studio provides options for converting PowerShell aliases into full cmdlet names, and forconverting full cmdlet names into aliases.
To convert a PowerShell alias into the full cmdlet name
Type a known PowerShell alias in the editor and then press <Tab>. The alias will be expanded into
the full cmdlet name.
For example, if you type the alias ps into the editor:

Pressing the < Tab > key after the ps alias expands it into its full cmdlet name, Get-Process:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

78

Script Editor

In a similar fashion, PrimalSense will expand parameter aliases into full names. If you type the alias cn into the editor:

Pressing the < Tab > key after the parameter alias Cn expands it into its full parameter name ComputerName:You can enable or disable alias expansion in Home > Options > Editor / PrimalSense > Enablealias tab expansion:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

79

Script Editor

To convert a full cmdlet name into alias
Right-click on the cmdlet name in the code editor and choose Convert to Alias. If a cmdlet has
more than one alias, PowerShell Studio will list them:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

80

Script Editor

PowerShell Studio provides two keyboard shortcuts for working with aliases:· Ctrl+Shift+A

Convert all of the aliases in the current code file to their full cmdlet names.
· Ctrl+B

Toggle the alias on the current line between full name and alias.
Aliases are great for minimizing the amount you need to type in the shell. When you are writing
scripts however, it is best to expand all of the aliases. This makes it easier for less experienced colleagues to understand your scripts, and greatly facilitates debugging.

5.7

Snippets

PowerShell Studio provides a collection of snippets to help you complete common coding tasks quickly.
You can also use the Snippet Editor 329 to create and edit snippets.

About Snippets
Snippets are small pieces of reusable code that can be quickly inserted into your scripts, thus saving
you time and reducing errors. This piece, or "snippet" of code, can vary from a full-fledged function
to a simple single line statement. Snippets come in a variety of languages such VBScript, PowerShell,
C#, etc.
PrimalScript and PowerShell Studio come with extensive libraries of reusable code snippets. You canalso save any text or code block as a snippet to automate code development. Snippets can include

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

81

Script Editor
placeholders; PrimalScript and PowerShell Studio will prompt you to supply values for these when
you use the snippet.

Snippets Panel
Use the Snippets panel to access and manage snippets:

To access the Snippets panel:· On the Home ribbon, in the Windows section, select Snippets from the Panels drop-down menu.

-OR· Chorded keyboard shortcut: Press Ctrl+Alt+P, release, then press S

Inserting Snippets
PowerShell Studio provides many options for inserting snippets into your code. The snippet will beinserted at the current caret position:· Type the first few letters of the snippet name in the code editor and PrimalSense will display a listof options. Arrow up or down to select the desired snippet, and then press <Tab> to insert it into
your file:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

82

Script Editor· Right-click (Ctrl+K) in the code editor and PowerShell Studio will display a snippet selector. Navig-

ate through the snippet folders using the Up / Down Arrow keys and the <Enter> key to select asnippet:· Follow any of these options to add a snippet to a script from the Snippets panel 250 :o Right-click on a snippet and select Insert.
o Double-click a snippet.
o Click the snippet and then press <Enter>.
o Drag a snippet and drop it in the code editor.

Custom Snippet Folder
You can add a custom directory to the Snippets panel, such as a network share or a local directory,
via Home > Options > Panels. Specify the folder path in the Custom Directory field:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

83

Script Editor

New snippets that you create will automatically be stored in the 'User' folder and are stored in:%Users%\<user>\AppData\Roaming\SAPIEN\User Snippets\PowerShell

5.8

Script Signing

Script signing is the process of adding a digital signature to scripts.

How to Sign a Script or Remove a Signature
You can sign a script or remove a signature from the Home > Edit > Sign Script menu:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

84

Script Editor-ORRight-click on the tab containing the file name at the top of the script editor:· Sign Script

Sign a script.
· Remove Signature

Remove an existing signature.

Script Signing Options
PowerShell Studio can automate script signing so that scripts are signed when saved or exported.
Script signing options can be configured in Home > Options > PowerShell > Windows PowerShell Security:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

85

Script Editor
To enable automatic script signing· Select the Automatically sign .ps1 scripts when saving checkbox at the bottom of the dialog.

To designate a preferred code signing certificate· Enter the certificate name in the Certificate in local store field.

PowerShell Studio also supports PFX format certificates.

5.9

File Encoding

You can change the encoding of an open file by selecting an option from the file encoding menu on thestatus bar:

· UTF-8-BOM· UTF-8· UTF-16 BE· UTF-16 LE

UTF-8-BOM supports international characters and is the default for new files.
You can set the default file encoding in File > Options > General.

5.10 Context Menu Options
Many of the functions available on the ribbon bar can also be accessed by right-clicking in the code editor.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

86

Script Editor
Script Editor - Context Menu Options

The context menu options will vary depending on the file type, the location of the cursor in the
document, and also if any characters are highlighted. For example, right-clicking within a documentthat is part of a Project will reveal project-related options, while right-clicking on a 'cmdlet' enables
the 'Convert to Alias' menu option.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

87

Script Editor
5.11 Functions and Parameters
PowerShell Studio provides tools that make it easy to quickly create functions, parameters, and parameter sets—the Function Builder 87 and the Parameter Builder 110 .

5.11.1 Function Builder
The Function Builder is a robust tool that simplifies the creation of complex functions. It is a time saverand can also be a learning tool for those who may not be familiar with the intricacies of creating an advanced function. This section covers creating and editing functions, including parameters and parametersets.
To launch the Function Builder
Position the caret in the code editor where you want to insert a new function, and then use one ofthese options:· On the Home tab > in the Edit section, click the Functions drop-down > then select Insert New

Function (Ctrl+Shift+E):-OR-· In the code editor, right-click and select Insert New Function (Ctrl+Shift+E):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Script Editor

88-OR· In the Functions panel click the Insert New Function button:

The Function Builder dialog will launch:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

89

Script Editor

If you hover over or click over a question mark, a pop-up help message will explain the respective field:

We will explore each field of the Function Builder in the following topics:· Function (Cmdlet) Name 90· Synopsis and Description 90· Cmdlet Binding 90· Output Type 91· Parameter Sets 92· Default Parameter Set 93· Parameters 93· Parameter Set Filter 97· Parameter Editor 99· Special Considerations 104

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

90

Script Editor
5.11.1.1 Function (Cmdlet) Name
The Function Builder provides fields for a Verb and a Noun.
The Verb field contains a combo-box with a list of approved verbs, and also provides the option toenter an unapproved verb if necessary:

5.11.1.2 Synopsis and Description
Enter a quick synopsis and a longer description in the Synopsis and Description fields:

The information provided here is used to generate the function's Comment-based Help.

5.11.1.3 Cmdlet Binding
Check the Enable Cmdlet Binding option if you want your function to behave like a cmdlet and takeadvantage of PowerShell's built-in parameters such as Debug and Verbose, and/or process input fromthe pipeline. Set the cmdlet binding attributes by using the properties grid:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

91

Script Editor

The property grid displays a Help description when you click on an attribute.
The Cmdlet Binding option will add the [CmdlingBinding] attribute to your function:

5.11.1.4 Output TypeThe Output Type combo-box allows you to specify the output type of the function by selecting from existing types or entering a type:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

92

Script Editor

The appropriate attribute will be added to your code:

PowerShell Studio also provides PrimalSense code completion for types and namespaces as you
enter content in the Output Type field.

5.11.1.5 Parameter Sets
The Function Builder allows you to define parameter sets, assign parameter sets to individual parameters, designate a default parameter set, and much more.
To define a parameter set
Type a name for the parameter set in the Name column. You can also specify an (optional) output
type for each parameter set:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

93

Script Editor

Defining a parameter set enables additional options within the Function Builder:
Before a Parameter Set is defined

Options enabled after a Parameter Set isdefined5.11.1.6 Default Parameter Set
Use the Default Parameter Set drop-down list to set the CmdletBinding attribute:

5.11.1.7 Parameters
The Parameters section of the Function Builder is used for adding or editing parameters, and you canalso filter the parameters displayed by using the Parameter Set Filter 97 .
To add a parameter· NamePowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Script Editor

94Enter the name of the parameter:· TypeSpecify the object type of the parameter:· Parameter Set

Assign the parameter to a parameter set:

-ORDefine a new parameter set:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

95

Script Editor

Multiple parameter sets can be assigned to a single parameter by using a comma separator:· Pos (Position)

Define the parameter's position attribute (optional):

By default, the parameter's position is determined by the ordering of the parameters.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

96

Script Editor
For parameters that are assigned to multiple parameter sets, you can define each position by using a comma separator:

The position values should follow the same ordering as the parameter set assignments.
· M (Mandatory)

Define the parameter as mandatory (optional):

To edit a parameterTo edit advanced parameter settings, click the Details button (Ctrl+E):

For more information about editing parameter details, see Parameter Editor 99 .

To remove a parameter
To remove a parameter, click the red X button:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

97

Script Editor

5.11.1.8 Parameter Set Filter
Use the Parameter Set Filter to view parameters by their assigned Parameter Set:

· Show All (Default)

Show all of the parameters.
· NoneShow only the parameters that are not assigned to a parameter set.
· < Parameter Set Name >Show only the parameters assigned to < Parameter Set Name >.
To work with the parameters assigned to a specific parameter set
Select the filter for a specific parameter set:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

98

Script Editor

The position (Pos) field now only shows the parameter's position within the selected parameter
set and no longer lists the other parameter set positions.

To move or swap parameter positions
When the view is filtered for a particular parameter set, use the Up and Down menu buttons tomove or swap the parameter positions:

When the default (Show All) filter is selected:· The Up and Down move buttons only change the order in which the parameters are declared in

the function.
· The Mandatory (M) check box refers to the parameter's first assigned parameter set.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

99

Script Editor
When a parameter set is declared, the generated function will now include a switch statement to help
you differentiate between the parameter sets:

5.11.1.9 Parameter Editor
Use the Parameter editor dialog to create a new parameter or edit the details of an existing parameter,
such as adding validation and aliases.

To create a new parameter
Click the New Parameter button (Ctrl+N).
To edit a parameter
Click the Edit Parameter button (Ctrl+E) on the row of the parameter that you want to edit.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

100

Script Editor

Parameter dialog field descriptions:· Parameter Name

The name of the parameter.
· Description

The description of the parameter that will appear in the Help comment.
· TypeSpecify the object type of the parameter.
Checking Switch Parameter will make the parameter a switch parameter (the same as typing'switch' in the type field).
· Parameter Set

Designate the Parameter Set, or add a new Parameter Set:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

101

Script Editor· Attributes

Set the parameter's attributes, such as marking the parameter as Mandatory:

A Help description is displayed when editing a parameter attribute.
· AliasProvides an alternative name for the parameter (optional).
· Default Value

Specify a default value for the Parameter (e.g., $env:ComputerName).
· Validation

Use the Add drop-down to add validation attributes to the parameter:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

102

Script Editor

Clicking a validation attribute will display a pop-up Help definition.
Once added, you can modify the validation attribute using the property grid:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

103

Script Editor

To remove a validation attribute
Select the validation attribute and click Remove:Once you have added all of the parameters and entered the information required, press the OK button in the Function Builder dialog to generate the code in your script:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

104

Script Editor

5.11.1.10 Special Considerations
It is important to be aware of the following considerations when using the Function Builder:
Renaming Functions
When you rename an existing function within the Function Builder, PowerShell Studio will open thePreview dialog if there are any references outside of the function declaration, allowing you to selectwhich of the function references you wish to update in the script.
Comment-Based HelpA Comment-Based help 112 block will be inserted in your script only if you enter information in the
Function Builder Synopsis or Description fields.
Comments in the Parameter Block
If the Function Builder encounters any comments in the function's parameter block, it will automatically assign the comment to the parameter's description—all parameter comments will be moved tothe comment-based help block.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

105

Script Editor
Name Validation
The Function Builder will prevent duplicate functions by checking if the function name already exists
in your script:

Undo Changes
You can undo changes in the Function Builder at any time by using the keyboard shortcut Ctrl+Z.

5.11.2 Create Functions from Selection
When inserting a new function you can select a section of script and the Function Builder will use the selected text as the body of the function.
The Function Builder will pick potential parameters and display the following dialog where you canselect the variables you want to convert into parameters:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

106

Script Editor

5.11.3 Editing Functions
Use any of these options to edit an existing function:· Position the caret on a function's declaration in the code editor, then on the Home tab > in the

Edit section, click the Functions menu > select Edit Function (Ctrl+Shift+Alt+E):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

107

Script Editor-OR· Right-click on a function's declaration in the code editor, and then select Edit Function(Ctrl+Shift+Alt+E):-OR· In the Functions panel, select a function and then click the Edit Function button, or right-click on afunction and select Edit:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

108

Script Editor

5.11.4 Importing Functions
PowerShell Studio allows you to import functions into your existing scripts or modules.
To import functions· On the Home tab > in the Edit section, select the Functions menu > then select Import Func-

tions:-OR· In the Functions panel, click the Import Functions button:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

109

Script Editor

You will be prompted to select the files that contain the functions. You can select and remove files at
any time. All functions in the selected files will be listed in the Import Functions dialog:

Select the functions that you want to import, and then click the Import button to insert the checked
functions in the script:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

110

Script Editor

5.11.5 Parameter Builder
The Parameter Builder is a quick and easy way to insert a new parameter block, create a new parameter,or edit existing script parameters.
The Parameter Builder and the Function Builder 87 share the same functionality, with the exception of the 'Name' portion of the builder.
To access the Parameter Builder· From the Home tab > in the Edit section, select the Edit Parameters button (Ctrl+Shift+P):-OR· Right-click in the editor and select Edit Script Parameters... (Ctrl+Shift+P):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

111

Script Editor

You can use the Parameter Builder to specify parameters, parameter sets, validation, and help comments:

When you are done editing the parameters, click OK and PowerShell Studio will produce a parameter
block for your script.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

112

Script Editor
5.12 Comment-Based Help
PowerShell Studio can automatically generate comment blocks for existing functions. This section explains how to generate comment-based help, and shows you how to use comment-based help templates.

Generating Comment-Based HelpUse any of these options to generate comment blocks for an existing function:· Position the cursor on the function's declaration in the code editor, and then on the Home tab > inthe Edit section, select the Generate Comment-Based Help button:-OR· In the Functions panel, right-click on a function and select Generate Comment-Based Help:-OR-

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

113

Script Editor· Right-click on the function's declaration in the code editor, and then select Generate Comment-

Based Help:

PowerShell Studio will insert a help comment tailored to the specific function:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

114

Script Editor

The help structure is inserted into the script, and you will need to add the descriptive text and edit asappropriate.
By default, the help comment is inserted before the function declaration (as shown above).

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

115

Script Editor
The help comment can be inserted inside the function declaration by selecting Home > Options> Editor > Editor Settings > Insert comment-based help Inside Function:

Displaying Help Keyword Information
PowerShell Studio's PrimalSense can provide assistance when you are editing comment-based help.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

116

Script Editor
Within the comment help block, type a " . " (dot) to trigger the help keyword menu. Scroll up or
down in the menu to highlight a specific keyword and display the keyword information. Press <Enter > to insert the highlighted keyword into the comment block:5.12.1 Comment-Based Help Templates
PowerShell Studio features the ability to create templates for the Generate Comment-Based Help 112 feature.

5.12.1.1 About the Comment-Based Help Template
The predefined comment-based help template contains the following:

The template file contains the typical comment-based help block with some token variables and asingle parameter section. When the user generates comment-based help for a function or file,
PowerShell Studio will read the template file. Depending on if the function already has commentbased help, it will behave as follows:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

117

Script Editor
If comment-based help is not present

PowerShell Studio will insert all of the sections inorder, as defined by the template.

If comment-based help is present

PowerShell Studio will check whether each section
within the template is present in the existing comment and insert if necessary. In addition, the existing comment's sections will be reordered to matchthat of the template's.

Parameter Section
The comment-based help template contains a single parameter section that defines each new parameter's text. Notice that there is no parameter name after .PARAMETER. When PowerShell Studiogenerates the .PARAMETER section in the template, it will place all of the function's parameters sequentially within the comment block.
For example, all of the parameters shown in the template above will be inserted sequentially after the.DESCRIPTION section and before the .EXAMPLE section.
Empty Sections
Empty sections will not be inserted. For example, if the .OUTPUTS section in the template above isempty after replacing the variables (the function has no output), PowerShell Studio will not include itin the generated comment.

5.12.1.2 Comment-Based Help Template Variables
When a comment block is inserted in a script, PowerShell Studio dynamically expands the following
template variables:%NAME%

Inserts the name of the function or file.

%TARGETTYPE%

Inserts "function" if the comment is for a function.
Inserts "file" if the comment is for a file.

%HELPURL%

Inserts the Help URL defined in the function's Cmdlet Binding attribute.

%PARAMETER%

Inserts the parameter name (Only valid within the Parameter section).

%EXAMPLE%

Inserts a generated example using the existing parameters.

%OUTPUTS%

Inserts a list of outputs determined by the Output attribute.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

118

Script Editor

For details about template variables and formatting, see File Type Templates > Template Variables 128 .

If you add a new parameter to an existing function, simply Generate Comment-Based Help
content again and PowerShell Studio will append any missing parameters to the comment block:5.12.1.3 Creating a Comment-Based Help Template
To create a comment-based help template
1. Right-click on the comment-based help you wish to convert into a template and select theCreate Comment-Based Help Template option from the context menu:

2. In the Save Comment-Based Help Template dialog, enter a file name and then click Save:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

119

Script Editor

The resulting template file will be saved as a ps1 file in the following folder:%AppData%\Roaming\SAPIEN\PowerShell Studio\Templates\Comment Help\
3. Edit the comment file to include the necessary sections, variables, and text. If the original comment-based help has one or more parameter sections, PowerShell Studio will automaticallyformat the .PARAMETER section for the template:

4. Save the file by clicking File > Save (Ctrl+S).
You can generate a new template from an existing template by using the predefined template
as a starting point and following the same procedure described above. PowerShell Studio's predefined templates are located in the following folder:%ProgramData%\SAPIEN\PowerShell Studio <yyyy>\Templates\Comment Help

5.12.1.4 Selecting an Existing Comment-Based Help Template
PowerShell Studio allows you to define multiple templates, which allows you to insert predefined comment-based help as needed.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

120

Script Editor
To insert the contents of a comment help template into your script
Position the caret in the function declaration and then on the Home tab > in the Edit section, click
the Generate Comment-Based Help button:

If more than one template exists, PowerShell Studio will present you with the following selection dialog:

Highlight the desired template to be applied, and then click Select.

5.12.1.5 Multi-line or Single-line Comments
The comment-based help templates 116 support either single-line comments or multi-line comments.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

121

Script Editor
If you prefer to use single-line comments you can create a template using single-line comments and,
when applied, any existing multi-line comments will be converted to single-line. If you have a multiline comment template, it will convert the existing single-line comments to a multi-line comment.
A template's formatting is not taken into account when generating comment-based help.

5.13 File Type Templates
PowerShell Studio provides templates for various file types, and also allows you to create new templates.

5.13.1 Using Predefined File TemplatesThis topic provides a list of the available predefined file templates and shows you how to create a script
using a predefined template.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

122

Script Editor
Predefined Templates
Template Type

File Extension

Description

PowerShell Script

ps1

Creates a PowerShell script file.

PowerShell Form

psf

Creates an empty PowerShell form.
For information on creating Form or Grid
templates, see GUI Designer > Form Templates 173 .

Module Manifest

psd1

Creates a PowerShell module manifest file.

Module Script

psm1

Creates a PowerShell module script file.

PowerShell Service Script

ps1

Creates a PowerShell service script. Used forthe service packaging engine.

PowerShell Class

ps1

Creates a PowerShell script file with a classdeclaration. When you use this template,PowerShell Studio immediately allows you torename the class directly withing the editor.
If you add the class template as part of a project, it will use the specified file name as thedefault name of the class.

C# FileC# File.cs

Creates an empty C# file. You can use thistemplate as a quick way of writing C# codefor the Add-Type cmdlet.

Text File

Text File.txt

Creates an empty text file.

Using Predefined File Templates
To create a script from a predefined template· On the Quick Access menu, select New (Ctrl+N):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

123

Script Editor-OR· On the File menu, select New (Ctrl+N):

If you know what template you want to use, you can select it directly from the Quick Accessmenu or the File > New menu.
Browse through the template categories in the New File dialog, then select a template and click
Open:

PowerShell Studio will open the template file in the script editor.
To quickly locate a particular template, use the drop-down menu to filter the templates by User
defined or Preset, or enter a term to search by tag/keyword:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

124

Script Editor

5.13.2 Creating New File Templates
If the predefined templates in PowerShell Studio do not meet your needs, you can create your own.

Creating New File Templates
To create a template
Create a new file or open an existing file or template.
Save the file, and then on the File menu > select Create Template:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Script Editor

125

The Create File Template dialog will open:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

126

Script Editor

Fill in the template properties and then click Save:· TagsPowerShell Studio will automatically set some default tags based on the file extension. You can
add additional comma-separated tags.
· TypePowerShell Studio supports two types of templates:o File (form)
This template is used for new files.
o GridThis option is used when exporting a GUI from the Database Browser or the WMI Browser.
To select a Grid template, the psf file must contain a DataGridView control.
· Creator

Your name. (The value for this field is taken from Home > Options > General > Username).
· Company

Your company details. (The value for this field is taken from Home > Options > General > Organization).
· Description

Description of the template purpose.
· Target Grid

This option is available if you are creating a grid template.
If you specified the %SNIPPET% variable in your script, the Create File Template dialog will include a
Snippet field where you can select the desired snippet to trigger when the template is loaded. The
selected snippet will be included with the template:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

127

Script EditorEnter a name for the template in the Save As dialog, and then click Save:

The file type must have the same extension as the file type you wish the template to be applied
to. For example, a file named UserTemplate.ps1 will only apply to .ps1 script files.
The new template will appear whenever you create a new file:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

128

Script Editor

Template Categories
Templates can be organized by categories (folders) to make it easier to browse your existing templates. When you save a template in the Save As dialog (shown above), the folder that you choose
to save the template to will determine the category.
The default location for user created templates is %AppData%\SAPIEN\PowerShell Studio\Templates\File Templates\PowerShell.
PowerShell templates are stored in a PowerShell folder[Template Directory]\File Templates\PowerShell\

PowerShell GUI forms (psf) are stored in a Forms folder[Template Directory]\File Templates\PowerShell\Forms

The default location can be changed in Home > Options > General > Directories > Template Directory.
You can create new categories by simply creating a new folder when saving your template.

5.13.3 Template Variables
PowerShell Studio supports template variables that automatically expand when a template is loaded.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

129

Script Editor
Template Variables%AppName%

PowerShell Studio name.

%AppVersion%

PowerShell Studio version.

%UserName%

The user name specified in the settings.

%Company%

The user company name specified in the settings.

%Year%

Current Year <yyyy>.

%Date%

Current Date <m/dd/yyyy>.

%Time%

Current Time <h:mm PM>.

%FileName%

Inserts the file's name. This will be empty for new non-project files.

%FileTitle%

Inserts the file name without the extension.

%ProjectName%

Inserts the file's project name.

%GUID%

Inserts a unique GUID.

%SNIPPET%

Inserts the snippet that comes with the template script. This ishandled automatically when creating a template.
Templates only trigger the first %SNIPPET% variable—subsequentuses of the variable will be ignored.

%SNIPPET:SHORTCUT%

Inserts the snippet with the matching shortcut.
This snippet must be present in the Snippet Panel and is not included with the template.
For example: %SNIPPET:MSGBOX% will insert the message box
snippet when the template is first loaded.

Template Variable Formatting
When using variables in your templates, it may be necessary to format the value for particular circumstances. For example, the template variables in PowerShell Manifest (psd1) are often containedPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

130

Script Editor
in quotes, therefore the value must be formatted/encoded to prevent it from breaking the existing
string.
To encode the value, use the following format:%VARIABLE:FORMAT%
Where VARIABLE is the name of the variable and FORMAT is the name of the formatting type.
Format Name

Description

PSSingle

Format for a PowerShell single-quoted string.

PSDouble

Format for a PowerShell double-quoted string.

C

Format for a C/C++ string.

HTML

Format for an HTML string.

ObjectFormat for object names (class/variable/members).

For example, use the following to format USERNAME into a single-quote PowerShell string:%USERNAME:PSSingle%
If you want the variable to be a name for an object, such as a class name, then use the Object
format:%FILETITLE:Object%
In some cases, variables may return an empty string and this may be undesirable, especiallywhen the variable is used for an object's name. The template format allows you to set defaults tohandle cases like these.

5.14 Rename Refactoring
Rename refactoring allows you to rename and update object references throughout the script for variables, controls, parameters, functions, events, class names, class member names, and more. Rename refactoring also provides a preview so you can quickly see where the object is used and selectively decide
if you want to proceed with any change.

How to Rename Objects
To initiate Rename Refactoring· Highlight the object you wish to rename, then right-click and select Rename (Ctrl+Alt+J):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

131

Script Editor-OR· Highlight the object you wish to rename, then on the Home tab > in the Edit section, click theConvert drop-down > select Rename:

The Rename dialog will open:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

132

Script Editor

Make your selections in the Rename dialog 132 , and then select OK.

Rename dialog field descriptions· New NameEnter the new name for the selected object.
· Object Type

Displays the type of object that you are renaming. Different settings will be updated, dependingon the type of object being renamed:
Enum

Updates the enumerator value declared in the script.

Event

Updates the control event variable and references in the designer.

Function

Updates the function declaration and function calls.

GUI Control

Updates the GUI control variable and updates any event name and return
variables for projects.

MethodUpdates the class methods and the class method references.

Parameter

Updates the parameter for the function and any calls using the parameter.

Property

Updates the class property and the class property references.

Variable

Updates variables within the document that aren't a parameter or GUI
control.

· ScopePowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

133

Script Editor
Select the scope for the objects that will be replaced. The list of available scopes will vary depending on the object type:
Current Scope

Rename refactoring occurs within the scope of the current function or
event block.

Entire Document

Rename refactoring will occur for all instances of the object within the entire document.

Entire Project

Rename refactoring will occur for all instances of the object within the
project files.

GUI Controls, Events, Parameters, and Functions will always apply to the scope when Entire
Document or Entire Project are selected.
· Preview Reference Changes

Presents the Preview dialog with a list of all the changes that will occur. This option is selected bydefault.
Click on any item listed in the Preview dialog to view the pending change in the script:

When you select an item in the Preview dialog, notice that the all of the other references in thescript are also highlighted.
Uncheck an item if you do not want that particular instance to be modified.
ing a GUI control you will not be able to uncheck items.

If you are renam-

To implement the selected changes, click Apply in the Preview dialog.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

134

Script Editor
Rename Refactoring in Projects
Rename refactoring is useful when dealing with multiple files in a project because it will update all of
the project files, with the exception of excluded files (e.g., project files that have their Build property
set to < -ExcludeProperty > ):In PowerShell Studio, return variables are updated when a GUI control is renamed. In addition, when
you rename a project file in PowerShell Studio, all the reference functions and return variables are
updated to reflect the new file name.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

135

Script Editor
If you include ps1 files as content and dot source the file within a project, calls to functions
defined in the dot sourced file can be updated using rename refactoring.

5.15 Verifying Your Script
PowerShell Studio provides a feature called Verify Script that checks if all of the cmdlets and modules required by your script are available on a target machine. This feature is especially useful for validating if
your script will run on a specific remote machine.
To run Verify Script
Select a machine from the Home tab > Platform section, Machine drop-down:

If you choose to select a remote machine you will need to import the remote machine's cache
before selecting the remote machine (Home tab > Platform section > Import Remote Cache button).
Verify the script from the Home tab > Edit section > Analysis drop-down > Verify Script:

PowerShell Studio will evaluate the script and provide the results in the Tools Output panel 259 , listing
any modules or cmdlets that are not on the target machine:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

136

Script Editor

PowerShell Studio's editor also offers a visual cue when a cmdlet is unknown:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

137

Running and Debugging Scripts
6

Running and Debugging Scripts

This section covers some of the primary options available when running and debugging scripts inPowerShell Studio.

6.1

Run and Debug Ribbon Controls

Common controls related to running and debugging scripts are located on the Home tab of the ribbon.
This section covers the options available in the Platform 137 , Run 140 , and Debug 142 sections of theHome ribbon.

Platform - Ribbon Options
The following options are available on the Home ribbon > Platform section:

Home tab > Platform section· Machine

Select the machine to run the script on. If you import a remote cache, the remote machine namewill be displayed in the drop-down list. 'Local Machine' is the default.
· Powershell Version / Platform 138

Select the desired version of PowerShell, and 64 Bit or 32 Bit.
· Enable / Disable Elevation 138

Toggles script execution and debugging in elevated mode.
· STA Mode 139

Runs the script in Single Threaded Apartment (STA) mode.
· Rebuild Local Cache 139

Rebuilds the local cache of PowerShell cmdlets and modules.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

138

Running and Debugging Scripts· Reload Cache 140

Reloads the PowerShell cache.
· Cache Editor

Add / remove modules that are included in the local cache profile.
· Import Remote Cache

Imports the Installed Module Set (IMS) exported on another computer.
· Edit Remote Connection

Edit the Remote Cache's Connection Settings.
· Remote Console

Open a remote shell to the selected machine (requires Windows Remoting).
Powershell Version and Platform
PowerShell comes in both 64-bit and 32-bit platforms. When you execute a script from PowerShell
Studio, you can choose the required platform from the Home tab > Platform section.
You can also select the version of PowerShell to run the script under:

You can also designate how and where a script will run using meta comments 143 .
Elevation
PowerShell Studio runs your scripts with the privileges of the current user. It is considered a security
best practice to avoid logging on as an 'administrator' level account whenever possible. Sometimes
your scripts will need to do things that require greater privileges—PowerShell Studio facilitates thisby allowing you to run scripts in elevated mode.
You can toggle between the elevated or non-elevated mode for script execution from the Home tab> Platform section > Enable/Disable Elevation button:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

139

Running and Debugging Scripts
Elevated

Not Elevated

STA Mode
STA (Single Threaded Apartment) mode allows you to start your script in single threaded mode. Thisis essential when your script uses forms to interact with the Windows GUI. Some GUI controls require
STA mode in order for them to function correctly. STA mode is activate by default.
You can toggle the STA Mode between active and inactive from the Home tab > Platform section >STA Mode button:
STA Mode - Active

STA Mode - Inactive

Cache Commands
There are two cache related commands:· Rebuild Local Cache

This command rebuilds the cache, including any new modules installed:

If you modified the cache with Cache Editor, PowerShell Studio will now prompt you before rebuilding the cache:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

140

Running and Debugging Scriptso To override the manual changes, select Yes.
o To cancel, Select No.
This safety check will help prevent accidentally undoing any manual changes made to thecache.
· Reload Cache

This command will reload the cache without making any changes:

Use this command to reload the cache after making changes with the Cache Editor.

Run - Ribbon Options
The following script execution options are available on the Home ribbon > Run section:

Home tab > Run section· Run

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

141

Running and Debugging Scripts

o Run (Ctrl+F5)
Executes the current document or project. The results are displayed in the Output panel.
o Run in Console (Ctrl+F8)
Executes the script or project in a console session. The results are displayed in the Console panel.
o Run Selection (Shift+F8)
Executes the highlighted text or the line that it is on. The results are displayed in the Output
panel.
o Run Selection in Console (F8)
Executes the highlighted text in a console session. The results are displayed in the Console panel.
· Remote

o Run Remotely (F6)
Uses PowerShell Remoting to execute the script or project on another machine. The results are
displayed in the Output panel.
o Run Remotely RSEE (Shift+F6)
Uses the SAPIEN Remote Script Execution Engine to execute the file on another machine.
o Debug Remotely (Ctrl+F6)
Debugs the current script or project on a remote system.The results are displayed in the Output
panel and the Debug Console.
· Monitor

Enables performance monitoring when running scripts and displays the output in the Performancepanel 228 .

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

142

Running and Debugging Scripts· Custom Tool

User defined menu of commands and tools.

Debug - Ribbon Options
The following debug options are available on the Home tab > Debug section:

Home tab > Debug section· Debugo Debug (F5)
Debugs the current script or project. The results are displayed in the Output and Tools Output
panels.
o Debug with Multiple Files (Ctrl+M)
Debugs the current script or project plus additional files and their breakpoints.
o Debug Remotely (Ctrl+F6)
Debugs the current script or project on a remote system. The results are displayed in the Output
panel and the Debug console.
· Stop (Shift+F5)

Stops the running script.
· Step Into (F11)

Step into the current function call.
· Step Over (F10)Single step.
· Step Out (Shift+F11)

Steps out of the current function.
· Run To Cursor (Ctrl+F10)

Runs the script to the line containing the cursor.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

143

Running and Debugging Scripts· Break

Breaks into the debugger.
· Breakpoints

See Working with Breakpoints 144 .
· Tracepoints

See Working with Tracepoints 146 .

6.2

Running Scripts

Many of the controls used when running scripts are located in the Platform 137 and Run 140 sections of
the Home ribbon. These controls are also contextually available 85 when you right-click in a script.

Using Meta Comments
PowerShell Studio allows meta comments to be used to change how and where your scripts are run.
You can run scripts in 32 or 64-bit mode, elevated or not elevated, remote or local, and so on. These
meta comments override your current platform settings. Many options can be changed or set via
meta comments such as:· # %ForceShell%=PowerShell 64 bit

Will invoke the PowerShell 64-bit shell and execute the script there.
· # %ForcePlatform%=64Will execute your script in 64-bit mode.
· # %ForceElevation%=yes

Will force elevation of your script.
· # %ForceHost%=REMOTE1

Will run the script on a remote machine named 'REMOTE1'.
Meta comments can be combined. For example, the following will cause the script to be run in 64bit mode and elevated:

You can also specify optional credentials. For instance, the following meta comments will force thescript to run on the remote machine 'REMOTE1' and will prompt for user name and password:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

144

Running and Debugging Scripts# %ForceHost%=REMOTE1,Prompt
The following meta comments will force the script to run on 'REMOTE1', but will only prompt for the
password for the user named 'User1':# %ForceHost%=REMOTE1,User1,Prompt

Available Meta Comments· %DebugParameters%· %ForceElevation%=true | false· %ForceHost%=Hostname[,User[,password]]· %ForceParameterPrompt%=true | false· %ForcePlatform%=32 | 64
· %ForceShell%=Name· %ForceSTA%=true | false· %Reference%

The %Reference% meta comment only affects PrimalSense—it will load the specified assemblyand provide PrimalSense for the .NET types contained within.
PrimalSense will offer suggestions when you type # in the code editor:

6.3

Debugging Scripts

This section provides an overview of tasks performed during debugging.

6.3.1

Working with Breakpoints

Breakpoints instruct the debugger to stop on a specified line of code, allowing you time to review what
the script is doing at that point.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

145

Running and Debugging Scripts
Breakpoints - Menu Options
The Breakpoints drop-down menu on the Home ribbon provides the following options:· Toggle Breakpoint (F9)Toggles the breakpoint on the current line.
· Enable / Disable Breakpoint (Shift+F9)

Enables or disables the breakpoint on the current line.
· Delete All Breakpoints (Ctrl+Shift+F9)

Deletes all breakpoints in the active document.
· Disable All Breakpoints

Disables all breakpoints in the active document.
· Set Variable Breakpoint...

Sets an advanced breakpoint when a variable is modified or accessed.
· Set Function Breakpoint...

Sets and advanced breakpoint when a specific function or command is called.
· Edit Breakpoints...

Opens a dialog to view and remove breakpoints.
To set a breakpoint· Left-click in the grey margin to the left of a line number.

-OR· Place your cursor on a line and select any of these options:o Press F9.
o Right-click to access the context menu > select Breakpoints > select Toggle Breakpoint.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

146

Running and Debugging Scriptso On the Home ribbon > in the Debug section > click the Breakpoints drop-down menu > selectToggle Breakpoint.
Active breakpoints are displayed as solid red circles in the margin of the code editor window, anddisabled breakpoints are displayed as red rings:

To disable or delete a breakpoint· Left-click in the grey margin to the left of a line number containing a breakpoint.

-OR· Place your cursor on a line containing a breakpoint and select any of these options:o Press F9 (Shift+F9).
o Right-click to access the context menu > select Breakpoints > select Toggle Breakpoint or Enable / Disable Breakpoint.
o On the Home ribbon > in the Debug section > click the Breakpoints drop-down menu > selectToggle Breakpoint or Enable / Disable Breakpoint.
Use the F9 or left-click toggle functions mentioned above to cycle through the Enable, Disable,
and Delete breakpoint options.

6.3.2

Working with Tracepoints

Tracepoints cause PowerShell Studio to write a message to the Output panel 226 when a particular line ofcode is executed.

Tracepoints - Menu Options
The Tracepoints drop-down menu on the Home ribbon provides the following options:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

147

Running and Debugging Scripts· Toggle Tracepoint (Ctrl+F9)

Toggles the tracepoint on the current line.
· Delete All Tracepoints (Ctrl+Shift+Alt+F9)

Removes all tracepoints in the active document.
To set a tracepoint· Place your cursor on a line and select any of these options:o Press Ctrl+F9.
o Right-click to access the context menu > select Tracepoints > select Toggle Tracepoint.
o On the Home ribbon > in the Debug section > click the Tracepoints drop-down menu > selectToggle Tracepoint.
Tracepoints appear as solid blue circles in the code editor margin:

When the code is executed, the tracepoint output is displayed in the Output panel:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

148

Running and Debugging Scripts

To delete a tracepoint· Place your cursor on a line containing a tracepoint and select any of these options:o Press Ctrl+F9.
o Right-click to access the context menu > select Tracepoints > select Toggle Tracepoint.
o On the Home ribbon > in the Debug section > click the Tracepoints drop-down menu > selectToggle Tracepoint.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

149

Running and Debugging Scripts
6.3.3

Passing Parameters

If your script begins with a Param block, PowerShell Studio will display a dialog box to allow you to select or enter values for script parameters:

To select or enter values in the Parameters dialog· Select previously stored parameter values from the Parameter Sets and History drop-down:-OR· Enter a new set of parameter values in the second text box with a space between each value:

Click OK to pass the selected values to the script.
The Clear History button allows you to remove all of the previously stored parameter values.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

150

Running and Debugging Scripts
6.3.4

Debug Panels

During a debugging session, PowerShell Studio displays a collection of panels to help you resolve problems in your code.
Panels used during debugging

6.4

Call Stack 208

Displays the function or procedure calls that are currently on the stack.

Debug Console 210

Customizable command line console (PowerShell, PSCore, Bash, etc.) thatallows you to interact with a debug session when at a breakpoint.

Output 226

Displays all script output including general application messages, build
information, errors, debug, verbose, and tracepoint output.

Tools Output 259

Displays output from external tools. When debugging, displays breakpoint notifications and post mortem messages.

Variables 261

Lists all variables and values in the current scope during a breakpoint
when debugging.

Watch 264

Displays the values of variables and expressions that you define when
debugging.

Running and Debugging RemotelyPowerShell Studio provides a number of options for running scripts or packages on remote machines,
and also allows you to debug remotely.

Running Scripts RemotelyPowerShell Studio supports two different mechanisms for executing scripts or packages on a remotemachine:· PowerShell Remoting 150· RSEE (Remote Scripting Execution Engine) Remoting 152

Using PowerShell Remoting
PowerShell Remoting must be configured on the target machine for remote script execution.
For more information, view a simple guide to installing and configuring PowerShell Remoting.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

151

Running and Debugging Scripts
To execute a file using PowerShell Remoting· On the Home tab > in the Run section, click the Remote drop-down, then select Run Remotely(F6).
The Remote Credentials dialog will open:· Either enter the name of the remote computer, or press the browse button

to launch theSelect a Computer window:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

152

Running and Debugging Scripts· After selecting a computer, enter the Username and Password credentials and then select OK. The

script will be executed on the selected machine and the results will be displayed in the Output
panel.
When you run a script remotely it cannot interact with the desktop, therefore you cannot include
any code that prompts the user for input (such as Read-Host, Get-Credential, or any forms).

Using RSEE Remoting
SAPIEN Technologie's RSEE service 379 must be installed and running on the target machine to use
RSEE remoting. The installation files (both 32 and 64-bit) can be found in:%Program Files%\SAPIEN Technologies, Inc\PowerShell Studio <year>\Redistributables
To execute a file using RSEE Remoting· On the Home tab > in the Run section, click the Remote drop-down, then select Run Remotely

RSEE (Shift+F6).
The Remote RSEE dialog will open:· Either enter the name of the remote computer, or press the browse button

to launch theSelect a Computer window:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

153

Running and Debugging Scripts· Choose a remote computer, then click Select. The script will be executed on the selected machine

and the results will display in the Output panel.

Remote Debugging
PowerShell Studio allows you to debug scripts as they run on another machine using SAPIEN Technologie's Remote Scripting Execution Engine (RSEE). RSEE must be installed on any machine that will
host remote scripts. The installation files (both 32 and 64-bit) can be found in:%Program Files%\SAPIEN Technologies, Inc\PowerShell Studio <year>\Redistributables

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

154

GUI Designer
7

GUI Designer

PowerShell Studio fully supports the creation of GUI scripts based on Windows Forms technology. A
number of predefined forms are included to get you started, or you can start with a blank form andbuild everything from scratch.

7.1

Forms Designer Introduction

The main editor screen for GUI scripts is the Forms Designer. This topic introduces you to the Designer
ribbon, and also the panels associated with the Designer.

Designer Ribbon
The Designer tab consolidates common tasks performed when designing and editing GUI forms:

The tasks available on the Designer ribbon correlate to what is selected in the form. For example,
selecting one form control will activate all of the tasks in the Position section, and selecting morethan one form control will active all of the tasks in the Alignment, Size, and Spacing sections.
The controls available on the Designer ribbon are covered in the relevant topics throughout the GUI
Designer 154 section.

Designer Panels
The Toolbox 255 and Properties 245 panels are used when working in the Forms Designer:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

155

GUI Designer

Toolbox Panel
The Toolbox panel 255 provides lists of controls and control sets that can be used when designing aPowerShell form.
· Controls are built in .NET controls.
· Control sets are custom controls built out of standard controls and custom scripts.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

156

GUI Designer
Controls

Control Sets

Select Tool
The Select tab is on the top of the Toolbox panel, to the right of the Control Sets tab. Use the Selecttool to select a control, which selects the control in the Designer and displays the control properties:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

157

GUI Designer

Use Shift+Click or Ctrl+Click to select multiple controls. When multiple controls are selected, theProperties panel displays only the properties that the selected controls have in common.

Properties Panel
The Properties panel 245 allows you to view and edit the properties of the currently selected control.
Each property has an associated editor to help guide you in choosing the correct value:

When you edit form controls in the Properties panel the changes are immediately reflected in the
Designer.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

158

GUI Designer
Pressing F1 when a control property is selected will open the related MSDN Help topic in abrowser window:

The Properties panel also displays the events that a control can respond to, and allows you to connect an event to code:

7.2

Creating a New Form

When creating a new form, you can start with an empty form or choose from a predefined template 173 .
To design a new form
Select File > New > New Form:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

GUI Designer

159

Select a form in the New File dialog, and then click Open:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

GUI Designer

160

The form will open in the Designer window of the main editor:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

161

GUI Designer

7.3

Working with Form Controls

This section shows you how to add a control or control set to a form, and how to work with form controls.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

162

GUI Designer

Adding Form Controls
To add a control or control set to a form
· Double-click the control or control set.
· Drag and drop the control or control set onto the form.
· Right-click on the control or control set and select Insert.

These images show a button control being dragged and dropped onto an empty form:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

163

GUI Designer

Manipulating Controls
The Edit section of the Designer ribbon contains a number of useful commands for working with
controls.

From left to right:· Edit - Select or remove controls:oSelect All - Selects all controls on a form (see Working with Multiple Controls 164 below).

oDelete - Delete(s) the selected controls.

· Alignment - Align controls to a particular edge:oAlign Lefts - Align left edges.

oAlign Bottoms - Align bottom edges.

oAlign Rights - Align right edges.

oAlign Tops - Align top edges.

oAlign Middles - Align middles.

o

Align Centers - Align centers.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

164

GUI Designer· Size - Resize a control to its content:oSize to Control - Size to control.

oSize to Control Width - Size to control width.

oSize to Control Height - Size to control height.

· Spacing - Equalize spacing between controls:oEqualize Horizontal Space - Makes the horizontal distances between the selected controls
equal.

oEqualize Vertical Space - Makes the vertical distances between the selected controls equal.

· Position - Location of the controls on a form:oCenter Horizontally - Center controls horizontally on a form.

oCenter Vertically - Center controls vertically on a form.

oBring to Front - Move controls in front of other controls.

oSend to Back - Move controls behind other controls.

o

Tab Order - Set the order in which a user moves focus from one control to another bypressing the Tab key.

Working with Multiple Controls
Working with multiple controls involves selecting more than one form control and applying thesame change to all selected controls.
There are a number of ways to select multiple controls at once:· Click on the first control, and then Ctrl+Left-click or Shift+Left-click to select the other controls.
· Left-click and drag to "lasso" and select individual controls as a group.
· On the Designer ribbon in the Edit section, click Select All

to select all of the controls on aform.
Once selected, any changes you make in the Properties panel or the Add Events dialog will be applied to all of the controls.
If you select more than one type of control, the Properties panel will only display the properties
and events that all of the controls share.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

165

GUI Designer
Control Spacing
The Spacing section of the Designer ribbon has two options to make the distances between the selected controls equal:

To make the horizontal distances between the selected controls equal
Select Equalize Horizontal Space:To make the vertical distances between the selected controls equal
Select Equalize Vertical SpacePowerShell Studio - Help Manual:© 2023 by SAPIEN Technologies Inc., all rights reserved

166

GUI Designer
Tab Order
Tab Order works to help you set the order in which you can tab through the form elements. Thismeans that when you press the Tab key in a form, each element will be highlighted in a certain order.
The Tab Order buttonon the Designer ribbon is a toggle—one click turns it on and anotherturns it off. Clicking Tab Order will display the tab order of the form items on the top-left of eachelement.

The tab order of the form elements is a zero-based array. Zero is the first tab, one is the second tab,etc. To change the tab order, click anywhere on an element to incrementally cycle through the available tab orders. When the last available tab order is reached, the numbering starts back at zero.
In the image above the tab order is button1, button2, checkedlistbox1.
In the image below the tab order has been changed to button1, checkedlistbox1, button2.

Control Property Smart Tags
As mentioned in the Forms Designer Introduction topic 157 , you can edit the properties of the currently selected control in the Properties panel. Some controls support another way of modifying
control properties called smart tags. These appear as a small icon on the top-right of a control when
it is selected in the forms designer.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

167

GUI Designer
This image shows the smart tag on a ComboBox control:

Clicking on the smart tag will display options specific to the control which provides an alternative,
task-oriented way of modifying control properties:

7.4

Preview GUI

The Preview GUI button allows you to preview the way a form will appear at run time without executing
any of your code. None of the controls will work when a form is in preview mode, but you can use theminimize and maximize buttons and also resize the form to make sure it behaves as expected. When
you are finished previewing the form, close the form to go back to the Designer.
To use Preview GUI
1. Click Preview GUI on the Designer ribbon (Ctrl+Shift+F5):

2. The Save As dialog will display if you have not yet saved the file. Enter a name for the file andclick Save:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

GUI Designer

168

3. The form is displayed:

7.5

Adding Events

The Add Events dialog is used to connect a control event to your code.
To add an event
Right-click on the control and choose Add Events (Ctrl+E):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

169

GUI Designer
The Add Events dialog launches:
Select one or more event in the Add Events dialog, and then click the Create button:

Perform a text search to filter the list of events and find the event you are looking for:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

170

GUI Designer

PowerShell Studio will add the required code in the script and indicate where you need to add yourown code:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

171

GUI Designer

If the control has a default event, right-click and select Edit Default Event (<event>) to automatically add the event code block to the script:

The default control event is added to the script, and the script editor will open with the caret at theposition where you can add your own code:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

172

GUI Designer

Event handlers can also be connected to a form or control from the Properties panel. To do this, first
select the form or control in the Designer. Then, in the Properties panel, click the lightning bolt button to display the assigned events. The image below shows the events for a form. The Load event
has been connected to a handler called form1_Load:To handle another event, simply double-click in the blank cell next to the event. PowerShell Studiowill create an event handler named $<object name>_<event name>.
For example, double-clicking in the blank cell to the right of the FormClosing event connects it to ahandler called form1_FormClosing:

The following code is added to the script:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

173

GUI Designer

You can also type the name of the event handler rather than double-clicking in the blank cell.
PowerShell Studio will use the name you type to generate the event handler.

7.6

Form Templates

A form template is a predefined form containing controls and script code. Templates help you create
GUI scripts quickly by doing much of the layout and code writing for you. This section shows you how
to use a predefined template, including grid templates, and also how to create your own templates.

7.6.1

Using Predefined Form TemplatesThis topic shows you how to use a predefined template to create a form.
To create a GUI based script from a template· From the Quick Access menu select New > New Form:-OR· Select File > New > New Form:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

174

GUI Designer

Select a template in the Forms section of the New File dialog, and then click Open:When you click on a template a small preview is displayed on the bottom-left. In the image below, the Tab Control form template is selected and the preview is displayed.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

175

GUI Designer

PowerShell Studio will create the form and associated scripts, and the form will open in the Designer
window of the main editor.
To search for a particular form, type the search criteria in the search field at the top of the dialog
and then press <Enter> to search:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

176

GUI Designer
7.6.2

Creating New Form or Grid Templates

If the predefined templates in PowerShell Studio do not meet your needs, you can create your own.
There are two distinct types of templates:· Form templates

A form template can be based on any existing form. It is a general purpose template.
· Grid templates

Grid templates 180 can only be created from an existing form that contains a DataGridView control.
These templates are designed to be used in conjunction with the Object Browser to rapidly create
forms that retrieve database records or WMI objects and display them in a grid.
To get started, create a new form and configure it as required including event handlers and anyother code.
Save your work and then from the File menu, choose Create Template:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

177

GUI Designer

You can also click the Create Form Template button in the Templates section on the Designer ribbon:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

178

GUI Designer

The Create File Template dialog will open:

Fill in the template properties:· TagsPowerShell Studio will prepopulate appropriate tags/keywords that describe the contents of thetemplate. You can add additional comma-separated tags.
· TypePowerShell Studio supports two types of templates:o File (form)o GridIf your form does not include a DataGridView control this option will not be available.
You can create a form template with a DataGridView control 180 by right-clicking an object in
the Database Browser 223 or WMI Browser 222 and selecting Generate Query Form....
· Creator

Your name. (The value for this field is taken from Home > Options > General > Username).
· Company

Your company details. (The value for this field is taken from Home > Options > General > Organization).
· Description

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

179

GUI Designer
A description of the purpose of the template.
· Target Grid

This option is available if you are creating a grid template. In cases where a form has more than
one grid, it allows you to specify which grid auto generated code will use.
Enter a name for the template and then click Save:

The default location for user created templates is %AppData%\SAPIEN\PowerShell Studio\Templates\File Templates\PowerShell\Forms. The default location can be changed in Home > Options> General > Directories > Template Directory.
The new template will appear in the list of standard templates whenever you create a new form:

Add Tags when you create the form template so that you can easily find it with a text search.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

180

GUI Designer
7.6.3

Working with Grid TemplatesThis topic explains how to work with grid templates.
If you right-click on a database table or WMI object in the Object Browser, the following menu appears:

The Generate Query Form… option will display a list of grid templates that include code to retrieve
objects and display them in a grid:

Placeholders are included in the template, allowing the code generator to reuse a template for different kinds of objects. These placeholders get replaced with object specific code when the template isused to create a grid form.
There are two placeholders:· %ResultsFunction%

This placeholder is replaced by a function declaration that returns the results of a query.
· %ResultsFunctionCall%

This placeholder is replaced by a call to the results function.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

181

GUI Designer
If you open the form file 'Grid.psf' from the built in grid template (%ProgramData%\SAPIEN\PowerShell Studio <year>\Templates\Grid Templates) and examine the code, you will
see the two 'results' placeholders:PowerShell Studio will create the code for the placeholders when you generate a a grid template
against a WMI object.
For example, right-click the CIM_NetworkAdapter object in the WMI Browser and select Generate
Query Form:

Next select the Grid template, click Open, and PowerShell Studio will generated the grid form withthe following code:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

182

GUI Designer

These placeholders allow you to control exactly how a user can interact with data, while leaving
PowerShell Studio to write the data retrieval code.
When you create a grid template from an existing form, PowerShell Studio will indicate if you havenot included the 'results' placeholders in your code:

You can elect not to include them if you would rather provide a fixed data retrieval implementation.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

183

GUI Designer
7.7

Exporting Form Scripts

You can export a script directly from the Deploy tab on the ribbon, in the Export section:

There are two export options:· Export to File - Exports the script to a ps1 file· Export to Clipboard - Copies the script to the clipboard.

Exporting creates a single stand-alone script that encapsulates all of the content of a script or package. The exported code can be placed on the clipboard or stored in a file. In both cases, PowerShell
Studio adds assembly load statements to the front of the exported code to make sure that it runs inthe same environment.
The PowerShell Studio export process can also add metadata, called recovery data, to the script. This
metadata allows PowerShell Studio to recreate the original project that was used during the export.
The recovery data is stored in multi-line comment blocks in the exported script.
Recovery data embedding is enabled by default (Home > Options > Designer > Embed recovery
data in exported scripts):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

184

GUI Designer

For information on the recovery options, see Options and Settings > Designer > Designer Settings 346 .
When an exported script is opened in PowerShell Studio and recovery data is present, PowerShell Studio will offer you the option of using the recovery data to recreate the project that was used
to create the script. Alternatively, you can open the script in the code editor.

7.8

Initializing GUI Controls

The Form control's Load event is a convenient place to initialize GUI controls because it is called right before the form is displayed:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

185

GUI Designer

Do not try to initialize a control outside an event block within the script:· The control might not exist when this line is executed by PowerShell.
· If the control does exist, your changes will most likely get overwritten by the designer generated

script.

Alternatives to the Load Event
It is possible to use other events to trigger initialization, such as the VisibleChanged event in PowerShell Studio's Chart - Disk Space control set. This event is triggered using the Visible property—
when the control is displayed (i.e., loaded), or when the control is hidden.

In the example above, the control set initializes when the control becomes visible by checking its Visible property.
If your initialization script is running slow, it can prevent the GUI from displaying in a timely manneror cause it to hang. In instances such as this, you might want to delay your initialization or simply
run the query in a separate job, then initialize and enable the controls after the job has completed
the query.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

186

GUI Designer
You cannot access GUI controls directly from a Job. You must return the results first and theninitialize the controls on the main thread / script.

7.9

Control Helper Functions

This topic explains control 'helper functions' and their rules, and also shows you how to add custom
helper functions.

About Control Helper Functions
Some controls are relatively complicated to work with directly from PowerShell, and may require
custom .Net code to be able to access all of their features. For those controls, PowerShell Studio
automatically creates helper functions that add useful .Net based methods into the form.
For example, when you add a ListView control to a form, PowerShell Studio adds two helper functions:
1. Update-ListViewColumnSort
This function enables sorting on any of the ListView's columns.
2. Add_ListViewItem
This function provides an easy way to add items to a ListView
To demonstrate this, create a new empty form in PowerShell Studio and look at the script that has
been created:

Now add a ListView control to the form and examine the code again. In the image below the helper
functions have been folded to reduce the size of the image:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

187

GUI Designer

A region called 'Control Helper Functions' has been added to the form and two functions have been
defined.

Adding Custom Helper Functions
As you build larger and more complex scripts, you will find it useful to build up a collection of helper
functions. Each control that has helper functions will have a folder named after the control. Each ofthese directories contains one or more PowerShell scripts that will be merged into existing codewhen the control is added to a form.
This is the default set of helper functions delivered with PowerShell Studio:

The default location for control functions is %ProgramData%\SAPIEN\PowerShell Studio<year>\Templates\Control Functions.
In the example below we will add a helper function to textbox controls that converts the text in a
textbox to uppercase.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

188

GUI Designer
First we create a folder called System.Windows.Forms.TextBox in the default folder location shown
above. The folder name must match the control type's full name:

Next we would create one or more scripts, one for each helper function.
In this example, we will create the script shown below:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

189

GUI Designer

The script file is saved as the helper function name ToUpper-TextBox in the System.Windows.Forms.Textbox folder:

The name of the function must be the same as the name of the script file, and there should be
only one file per script.
Now when we add a textbox to a form in PowerShell Studio, our helper function will be included
along with the standard code as shown below:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

190

GUI Designer

Helper Function Rules· The folder must be named after the control type's full name.
· The file name must match the function name.
· Each file should only contain a single function.

Failure to follow these rules can result in the insertion of multiple copies of the same function.

7.10 Property Sets
A property set is a collection of property settings that can be applied together to one or more controls.
Property sets enable you to quickly create a consistent look and feel to your forms by applying a groupof properties to existing controls, such as anchoring, font, and coloring. A property set can be generic,or specific to a particular type of control. This topic shows you how to apply and create property sets.

Applying Property Sets
To apply a property set
Select one or more controls on a form and then click Apply Property Set on the Designer ribbon:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

191

GUI Designer

Or you can right-click on a control and select Apply Property Set (Ctrl+L).
The Select Property Set dialog will appear:

In this example we are applying a property set to a button control. PowerShell Studio provides six
general styles and two that are specific to buttons.
Selecting the Show property sets for same type only check box will filter the list to show styles that
apply directly to the selected control type:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

192

GUI Designer

Select a property set and then click Select to apply it.
If you modify a property set after you have applied it to controls, you must reapply it to thosecontrols. Your changes will not be automatically applied.

Creating Property Sets
You can create your own property sets that encapsulate local branding requirements or other standard settings.
To create a property set
Configure all of the control properties that you want to capture, then select a control and click
Create Property Set on the Designer ribbon:

Or you can right-click on a control and select Create Property Set (Ctrl+Shift+L).

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

193

GUI Designer
The Create Property Set dialog allows you to configure the new property set:

Configure the options in the Create Property Set dialog and then click Create:· Limit to:a. Any TypeThe property set can be used with any type of control.
b. Matching TypeThe property set can only be used with controls that are the same type as the source control.
· Creator NameYour name. (The value for this field is taken from Home > Options > General >Username).
· Company

Your company details. (The value for this field is taken from Home > Options > General > Organization).
· Description

Provide a description of the property set. This field is mandatory.
· Select Properties

Select the properties that should be captured by the property set.
Enter a name for the property set and click Save:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

194

GUI Designer

The default location for custom property sets is %AppData%\SAPIEN\PowerShell Studio<year>\Templates\Property Sets.
The next time you apply a property set, the new property set will appear in the property set list:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

195

GUI Designer

There is currently no way to alter a property set—they must be recreated and reapplied to thecontrol.

7.11 Control Sets
In the same way that property sets 190 allow you to group together property settings for reuse, control
sets address common PowerShell scripting scenarios by combining multiple controls and script code
into new custom controls that can be added to forms just like standard controls. This topic shows you
how to insert and create control sets.

Inserting Control Sets
Control sets are located in the Control Sets tab of the Toolbox panel:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

196

GUI Designer

To add a control set to a form
Use any of these options to add a control set to a form:· Double-click the control set.
· Drag and drop the control set onto the form.
· Right-click on the control set and select Insert.

In some cases, a control set will need to add code to certain event handlers before it can work.
PowerShell Studio will display the following dialog if this is required:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

197

GUI Designer

You can select from the following options:· Append (Default / Recommended)

Leaves the event assignment as is, but also assigns the control set's event block via the script editor—this allows the control to assign more than one script block to the event.
· Leave

Leaves the event assignment as is.
· Replace

Replaces the existing assignment in the designer with the control set's new event block.
Event Dialog
There are three options in the Control Sets' Replace Event dialog: Append, Leave, or Replace.
When you select Append, the form's event is assigned below the new event script block:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

198

GUI Designer
This allows you to use multiple control sets that share the same events without them interferingwith one another.
In the code shown below, the form Load event handler ($form1_Load) has been customized to write
information to the debug pipeline:

We can see from the form properties that this handler has been connected to the form's Load event:If we now add the 'Fade in Effect' control set and choose Replace, the following changes occur:
1. New code is added, without affecting any existing code:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

GUI Designer

199

2. The form's Load event is now connected to the new code:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

200

GUI Designer

Now the Write-Debug statement is not executed because the original load event will not becalled.
If we had selected Leave instead of Replace in the example above, the control set code would havebeen added without connecting the form's Load event to the new event handler, thus leaving it to us
to connect things as we want.
A simple code addition will allow us to call the original event, or a new event. For example,
adding the following line will execute the code stored in the variable $form1_fadeInLoad:&$form1_fadeInLoad

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

201

GUI Designer
Creating Control Sets
Creating your own control sets is another way to build reusable components for your scripting tasks.
To create a control set, add controls to a form, configure their properties, and write all of the code
required to make your new control set function correctly. Then select all of the controls that are to be
included in the control set and click Create Control Set on the Designer ribbon:

Or you can right-click on the Designer and select Create Control Set (Ctrl+T).
The Create Control Set dialog allows you to configure the new control set:

Configure the options in the Create Control Set dialog (General tab) and then select Next:· Control Icon

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

202

GUI Designer
Choose the icon to associate with the control when it is displayed in the Toolbox panel 255 .
· Creator NameYour name. (The value for this field is taken from Home > Options > General > Username).
· Company

Your company details. (The value for this field is taken from Home > Options > General > Organization).
· Control Set Description

Provide a description for the control set. This field is mandatory.
· Control Insertion

If you have included any non-visual controls you can use the Control Insertion section to define
what happens when your custom control is added to a form. You have three choices as described
below.
a. Always
If you add your new custom control to a form that already has a control called timer1, PowerShell Studio will rename the new timer and modify the code in your custom control to use the
new name.
b. Use Existing TypeIf the destination form already has a control of the same type (Timer in the example) thenPowerShell Studio will not add a new control but rather modify the code to refer to the existing
control.
c. Use Existing Type (Match Name)
If the destination form already has a control of the same type (Timer in the example) and thename matches the name in your custom control, PowerShell Studio will behave as in b (i.e., use
the existing control).
If the names do not match, then PowerShell Studio will add everything in your custom control
to the form (i.e., it will behave as in a).
On the Functions tab you can choose to include any functions from your code in the template.
PowerShell Studio will automatically include functions that are bound to events in the control:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

203

GUI Designer

Click Next to go to the Events tab where you can mark an event as shared.
When you check the Shared checkbox next to an event, it will tell PowerShell Studio to share theevent over multiple instances of the control set. It does this by first checking if the event already exists:· If the event does not exist, then it will insert the event.
· If the event does exist, it will simply use the existing script block whenever a control triggers theevent.
The TextBox-Watermark control set in PowerShell Studio serves as a good example for event sharing. The script blocks to display the watermark are identical for all instances of the control set, andtherefore it doesn't make sense to create a new instance of the same event block every time the control set is inserted.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

GUI Designer

204

Click Finish, enter a file name and click Save:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

205

GUI Designer
The default location for custom control sets is %AppData%\SAPIEN\PowerShell Studio<year>\Templates\Control Sets.
The control set is added to the Control Sets tab in the Toolbox panel 255 .

If you include an entire form in a control set, PowerShell Studio will add the Container tab to theCreate Control Set dialog:

The Container tab helps you to specify which form property values and event handlers should be included in the control set.
The next time you need to use your new control set, simply drag it from the Toolbox panel 255
onto a form.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

206

Panels8

PanelsPowerShell Studio has dockable window panels that are used by dedicated features or to display output. This section provides an overview of the available panels and their content.

Accessing Panels
Some panels appear as a tab in a group of panels. If you move panels around or close a panel andcannot see it, you can access the panel from the ribbon (View > Panels) or by executing the associated chorded keyboard shortcut: Press Ctrl+Alt+P, release, then press the corresponding characterkey of the chord.
The panels and their chorded keyboard shortcuts are listed in the table below, and also in the Keyboard Shortcuts 398 topic.

PowerShell Studio Panels
Panels available in PowerShell Studio:

Panel

Keyboard Shortcut

Description

Call Stack

Ctrl + Alt + P, K

Displays the function or procedure callsthat are currently on the stack. Used indebugging.

ConsoleCtrl + Alt + P, C

Hosts PowerShell and other embedded
consoles in a separate process.

Debug Console

Ctrl + Alt + P, D

A customizable command line console(PowerShell, PSCore, Bash, etc.) that allows you to interact with a debug session
when at a breakpoint.

File Browser

Ctrl + Alt + P, I

Provides direct access to folders and files
on your hard drive.

Find Results

Ctrl + Alt + P, R

Displays Find in Files and Find All References search results.

Function Explorer

Ctrl + Alt + P, F

Lists all functions, events, workflows, andconfigurations referenced in the current
file. When working in a project, functions

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

207

Panelsdefined in other project files are also displayed.
Help

Ctrl + Alt + P, H

Displays Windows PowerShell commandline help and WMI Help (F1).

Object Browser

Ctrl + Alt + P, B

Displays Windows PowerShell modules
and commands, .NET Framework types,
WMI objects, and database objects.

OutputCtrl + Alt + P, O

Displays all script ouptut including general application messages, build information, errors, debug, verbose, and tracepoint output.

Performance

Ctrl + Alt + P, M

Displays the CPU and memory usage ofyour PowerShell scripts.

Project

Ctrl + Alt + P, J

Central location for managing projects,
including the project's files and folders.

Properties

Ctrl + Alt + P, P

View and edit the control properties
when working in the GUI Designer. Edit
project settings and project file settings
when working in a project.

Snippets

Ctrl + Alt + P, S

View and manage preset and userdefined snippets (reusable text and code).

ToolboxCtrl + Alt + P, T

Displays Windows Forms controls andcontrol sets that are available in the GUI
Designer.

Tools Output

Ctrl + Alt + P, L

Displays output from external tools.
When debugging, displays breakpoint
notifications and post mortem messages.

Variables

Ctrl + Alt + P, V

Lists all variables and values in the current
scope during a breakpoint when debugging.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

208

PanelsWatch

Ctrl + Alt + P, W

Displays the values of variables and expressions that you define when debugging.

To quickly access a panel, execute the associated chorded keyboard shortcut. Simply press
Ctrl+Alt+P, release, then press the corresponding character key of the chord.

8.1

Call Stack Panel

The Call Stack panel is used during debugging to display the function or procedure calls that are currently on the stack.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press K.

Call Stack Panel Overview
The Call Stack panel displays the execution path through your script to the current breakpoint when
debugging. Each line, except the first, represents a point where your script called a function. The firstline is the location of the current breakpoint. Double-clicking on a line in this window will take you tothat distinct line in the code editor:

8.2

Console Panel

The Console panel hosts PowerShell and other embedded consoles in a separate process.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press C.

Console Panel Overview
You can interact with your script in the Console panel, which has three component parts:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

209

Panels· Platform Selector

Select from the list to activate a preconfigured console.
· Output Window

The Console output window displays the results of any command you send to the shell.
· Command Input

Type commands here and press < Enter > to send them to the shell. By default this option is disabled. To enable Command Input go to the Home tab > Options dialog > Console tab and selectEnable enhanced console input line.

Console Panel - Context Menu Options
Right-click in the Console window to display the following options:· CopyCopy text highlighted in the Console window to the clipboard.
· PasteCopy the contents of the clipboard into the console.
· Restart Shell

Restart the shell. This will erase all work done in the current shell.
· Cancel Execution

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

210

PanelsCancel the script / command that is executing in the console.

8.3

Debug Console

The Debug Console is a customizable command line console (PowerShell, PSCore, Bash, etc.) that allows
you to interact with a debug session when at a breakpoint.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press D.

Debug Console Overview
With the Debug Console, you can interact with the RunSpace while at a breakpoint. The console allows you to run commands or alter values in order to make debugging scripts easier. You can also
simply experiment with what-if scenarios.

Arrow up and down to scroll through the history of commands in the active session.

Debug Console - Context Menu Options
Right-click in the Debug Console window to display the following options:· Copy (Ctrl+C)

Copy highlighted text to the clipboard.
· Find (Ctrl+F)

Search the text in the Debug Console panel.
· Select All (Ctrl+A)

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

211

PanelsSelect all of the text in the Debug Console panel.
· Clear (Ctrl+E)

Clear the Debug Console panel.

8.4

File Browser

The File Browser provides direct access to folders and files on your hard drive.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press I.

File Browser Overview
Access the files and folders on your hard drive directly from the File Browser:

File Browser - Buttons and Search
There are six buttons, a search box, and a location field at the top of the File Browser:

From left to right:··

Select Folder
Select a different folder in your environment as the current folder.
ReloadPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

212

PanelsReload the current folder.
·

Collapse All
Collapse all expanded nodes in the folder.

·

Previous Folder
Select a previously used folder as the current folder.

·

New Folder
Create a new empty folder in the current directory.

·

New File
Create a new file.

·

SearchScans the current directory and displays all of the matching results.

· Location

Displays the current directory.
Hover over the location field to see the full directory path:

File Browser - Context Menu Options
Right-click on a folder or file to display the following options:· Open Folder

Opens the corresponding folder for the highlighted file or folder.
· Addo New File
Launches the Add File dialog to add a new file to the current directory.
o New Folder
Adds a new folder to the current directory.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

213

Panels· Rename

Highlights the file or folder name for editing.
· Delete

Deletes the highlighted file or folder.

Using the File Browser
There are a number of ways to open a file from the File Browser, and you can also dot source a filefrom the File Browser.
To open a file
· Double-click a file in the File Browser to open it in PowerShell Studio.

-OR· Drag a file from the File Browser and release it in the PowerShell Studio workspace.

To dot source a file
· Hold Shift and drag a file from the File Browser into your open script to dot source the file:

8.5

Find Results Panel

The Find Results panel displays Find in Files 64 and Find All References 68 search results.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press R.

Find Results Panel Overview
The Find Results panel automatically displays results generated from queries performed using the Find
in Files 64 dialog and the Script Editor's Find All References 68 option.
The results displayed include the associated file path, file name, and line number (#):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

214

PanelsDouble-click on a search result to view the referenced line in the script. Viewed results are distinguished by a green check mark on the left column:

The check mark indicator helps you keep track of all the locations you visited.
To manually mark a result as visited or unvisited, right-click on a result and select Mark as Visited orMark as Unvisited:

If you are working with a project, references located in the other project files will also display in
the Find Results panel.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

215

Panels8.6

Function Explorer Panel

The Function Explorer lists all functions, events, workflows, and configurations referenced in the current
file. When working in a project, functions defined in other project files are also displayed.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press F.

Functions Panel Overview
The Functions panel displays all of the functions, events, and workflows in the current context.
When you are working on a single script, the functions and workflows within that script are displayed. When working in a project, all available functions in the project are displayed:
Single Script

Project File

Functions Panel - Buttons and Search
There are three buttons and a search box at the top of the Function Explorer panel:

From left to right:·

Insert Function

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

216

PanelsOpens the Function Builder where you can create a function.
·

Edit Function
Opens the highlighted function in the Function Builder.

·

Import Functions
Launches the Import Functions dialog along with an Explorer window for locating the file containing the functions to import.

·

SearchSearch for a function, workflow, or event by typing the first few letters in the search box. As you
type, PrimalSense™ will give you a list of possible completions.

Hover over a function to display the function name and details:

Functions Panel - Context Menu Options
Right-click on a function to display the following options:· Go to Declaration

Positions the caret in the relevent file at the source code for the selected function.
· Find All References

Find all references 68 to this function in the script or project. Results are displayed in the Find Results panel 213 .
· Insert

Inserts a function call at the current caret position.
· Generate Comment-Based Help

Generates and inserts templated comment-based help for the selected function.
· EditPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

217

PanelsEdit the function in the Function Builder.
· CopyCopies the function definition to the clipboard.
· Rename

Renames the function and updates the references in the script or project.

8.7

Help Panel

The Help panel displays Windows PowerShell command line help and WMI Help (F1).
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press H.

Help Panel - Buttons and Search
There are three buttons on the top-left of the Help panel:

From left to right:·

Go Back (Alt+Left)
Navigates backwards through the help files that have been loaded since PowerShell Studio wasstarted.

·Go Forward (Alt+Right)
Navigates forwards through the help files that have been loaded since PowerShell Studio was started.

·

Find (Ctrl+F)
Searches the text in the Help panel.

Help Panel - Context Menu Options
Right-click in the Help panel to display the following options:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

218

Panels· Copy (Ctrl+C)

Copies the highlighted text to the clipboard.
· Find (Ctrl+F)

Searches the text in the Help panel.
· Select All (Ctrl+A)

Selects all of the text in the Help panel.

8.8

Object Browser

The Object Browser displays Windows PowerShell modules and commands, .NET Framework types,
WMI objects, and database objects.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press B.

Object Browser Overview
The Object Browser is one of the most useful features of PowerShell Studio and contains the following browsers:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

219

PanelsPowerShell Browser 219

For exploring PowerShell objects including cmdlets, aliases, modules,
functions, and About Help topics.

.NET Object Browser 221

For exploring .NET types.

WMI Browser 222

For exploring the WMI database on your computer.

Database Browser 223

For exploring databases.

Each browser provides the same basic functionality—the ability to explore a collection of objects.
Each browser also provides custom capabilities to help you integrate objects into your code.

PowerShell Browser
The PowerShell browser displays PowerShell cmdlets, aliases, modules, and About Help topics:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

220

PanelsSearch for a PowerShell cmdlet, alias, module, or About Help topic by typing the first few letters inthe search box. As you type, PrimalSense™ will give you a list of possible completions:PowerShell Object - Context Menu Options
Right-click on a PowerShell object to display options available for the object:· Insert

Inserts the selected command into a script file. If you insert a command from a module, thenPowerShell Studio will also add the appropriate Import-Module command into your code.
· Add To ProjectPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

221

PanelsInserts an import statement in the primary file of the project (Startup.pss or Module.psm1).
· CopyCopies the object name to the clipboard.
· Refresh Help

Refresh Help will rebuild the cache help for the selected module. If no help is found, it will trigger
this command automatically.
· Show Help

Displays PowerShell help about the object in the Help panel.
· Online Help

Displays help from the Microsoft web site in a browser window.

.NET Object Browser
This browser displays the .NET assemblies available on your computer. Each assembly can be
opened to reveal the namespaces and types contained within. Individual types can be opened to reveal their contents (properties, methods etc.):

Search for .NET assemblies by typing the first few letters in the search box, then press < Enter > tosee the first result. Continue pressing < Enter > to cycle through the search results:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

222

Panels.NET Object - Context Menu Options
Right-click on a node to display the following options:· Insert

Inserts the name of the current node into your script.
· MSDN Help

Accesses the MSDN help website for the selected type, method, property etc.
· Select Member Type

Selects the current item's type, such as a Property's or Method's return type, in the .NET Object
Browser.
· CopyCopies the current node name onto the clipboard.
· Assembly Included

Indicates whether the assembly is loaded into the current document. You can check or uncheck theassembly in order to add or remove the assembly.

WMI Browser
The WMI browser displays namespaces and objects from the WMI database on your computer. As
you click on nodes in this panel, PowerShell Studio will display information and code examples
about the node in the Help panel:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

223

PanelsLook for namespaces or WMI objects by typing in the search box, then press < Enter > to see thefirst result. Continue pressing < Enter > to cycle through the search results:

WMI Object - Context Menu Options
Right-click on a WMI object to display the following options:· Insert

Inserts a Get-WMIObject command into a script to retrieve all instances of the selected WMI object.
· MSDN Help

Displays MSDN help for the selected WMI object.
· CopyCopies the object name into the clipboard.
· Generate Query Form...

Generates a form template 173 that displays all instances of the selected WMI object in a grid.

Database Browser
The database browser allows you to explore databases and generate code to read and display data:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

224

Panels

The same database browser is shared with PrimalScript. Any connections created in PrimalScript
will display in PowerShell Studio, and vice versa.
How to create a database connection
The first step in using the database browser is to create a database connection.
Click on the create connection button (PowerShell Studio - Help Manual) to launch the connection dialog:© 2023 by SAPIEN Technologies Inc., all rights reserved

225

Panels
The code generators provide a default connection string that you will need to edit to reflect your environment. Once your database connection is configured, press Save to add a new node to the
database browser. Click on the node to enumerate the contents of the database, which allows you totunnel into the tables, views, stored procedures, etc.
Search for a database, table, or field by typing in the search box, then press < Enter > to see the first
result. Continue pressing < Enter > to cycle through the search results:

The search function includes both active and cached database connections.
Database Connection - Context Menu Options
Right-click on a database connection to display the following options:· New Database Connection

Creates a new database connection.
· Insert

Inserts the name into the Editor.
· Copy Connection String

Copies the database connection string to the clipboard.
· EditEdits the database connection.
· Rename

Renames the database connection.
· Refresh

Refreshes the Database Browser window.
· Delete

Deletes the database connection.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

226

PanelsDatabase Objects - Context Menu Options
Right-click on a database object to display the following options:· Insert

Generates a PowerShell function that uses ADO.Net to retrieve all records from the database andoutput the records to the PowerShell pipeline.
· Refresh

Refreshes the Database Browser window.
· CopyCopies the name of the database object onto the clipboard.
· Generate Query Form...

Creates a PowerShell form based on available templates, and ADO.Net code, to retrieve databaserecords into a .Net DataSet object and display the results in a grid.
· Generate Query PowerShell Script...

Creates a PowerShell script that uses ADO.Net to retrieve all records from the database and output
the records to the PowerShell pipeline.
Dragging and dropping a database object to the Script Editor will insert a function, whereas
dragging and dropping a database object to the Designer will insert a grid with a function call.

8.9

Output Panel

The Output panel displays all script output including general application messages, build information,
errors, debug, verbose, and tracepoint output.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

227

PanelsKeyboard Shortcut
Press Ctrl + Alt + P, release, then press O.

Output Panel Overview
The Output panel displays messages written to the debug stream (e.g., from the Write-Debug cmdlet), records messages created by tracepoints in your code, and displays verbose output:

If the output contains the line number, you can double-click on an error message to go to that
distinct line in the code editor.

Output Panel - Context Menu Options
Right-click in the Output panel to display the following options:· Copy (Ctrl+C)

Copy highlighted text to the clipboard.
· Copy HTML (Ctrl+Shift+C)

Copied highlight code, including color coding and formatting.
· Find (Ctrl+F)

Search the text in the output panel.
· Select All (Ctrl+A)

Select all of the text in the output panel.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

228

Panels· Clear (Ctrl+E)

Clear the output panel.

8.10 Performance Panel
The Performance panel displays the CPU and memory usage of your PowerShell scripts..
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press M.

Performance Panel Overview
The Performance panel displays the CPU and memory usage of your scripts when you have performance monitoring enabled.
The performance monitor does not record the statistics during degugging because the results
would be skewed due to line breaking and variable querying.
How to enable performance monitoring
To enable performance monitoring when running scripts, click the Home tab on the ribbon bar, thenin the Run section select the Monitor checkbox:

When performance monitoring is enabled, the CPU and memory usage of your scripts are displayed
graphically in real-time during script execution:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

229

PanelsHow to view specific performance data
Scroll your pointer across the graph and hover over a data point to see the CPU and memory usage
details:

The Performance panel will display the last three results of a script so that you can compare the performance differences of each run through:How to clear the performance data
To clear the data from the Performance panel, right-click anywhere in the panel and select Clear:

How to size the Performance panel
The graph in the docked Performance panel scales automatically as the script runs, but some details
may not be visible if the docked window is sized at a small height. To see the performance data de-PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

230

Panelstails in a broader view, depending on the current Performance panel location either right-click on the
Performance panel title bar and select Dock as Tabbed Document, or Float; or drag the Performance panel tab away from the tabbed group and release to float the panel.

For information on docking and undocking panels, see Working with Panels 35 .
When the script ends the peak values that occurred during script execution are displayed in the
Output panel:

8.11 Project Panel
The Project panel is a Central location for managing projects, including the project's files and folders.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

231

PanelsKeyboard Shortcut
Press Ctrl + Alt + P, release, then press J.

Project Panel - Buttons and Search
There are four buttons and a search box at the top of the Project panel:

From left to right:·

New File launches the Add File dialog where you can select a file template and add a new fileto the project.

·

Add Existing File launches the file browser so that you can select a file to add to the project.

·

New Folder allows you to add a new folder directly to the project.

·Open Project Folder launches File Explorer focused in the currently highlight folder.

·

Search in a project by typing the first few letters in the search box. As you type, PrimalSense™
will filter and display the files and folders containing your search criteria.

Module Buttons
Three additional buttons are available at the top-right of the Project panel when you have a module
project open:

From left to right:·

Open Module Folder
Opens the exported module directory.

·

Clear Module Folder
Deletes the contents of the exported module directory.

·

Build Module
Builds and exports the module to the user's Windows PowerShell Modules directory: C:\Users\<user>\Documents\WindowsPowerShell\Modules

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

232

PanelsThe module manifest is automatically updated when you build the module project.

Project Panel - Context Menu Options
The context menus in the Project panel provide useful options for building and working with projects.
The context menu options available in the Project panel will vary depending on whether the item
selected is a project, folder, or file, and the menu options will further vary by file type. If you selectmultiple files the context menu options will vary depending on the files selected.
Project - Menu Options
Right-click on a project name to access the following options:· Rename

Renames the project.
· Addo Existing File...
Launches the file browser to select a file to add to the project.
o New File...
Launches the Add File dialog to add a new file to the project.
o New Folder...
Adds a new folder to the project.
o Add Git Ignore File
Creates a .gitingnore file to filter out any temporary project files (for Git source control).
· Open Project Folder...

Opens the project directory in File Explorer.
· Run Project

Runs the project.
· Run Project in Console

Runs the project in the console window.
· Close ProjectPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

233

PanelsCloses the project.

Project Folder - Menu Options
Right-click on a folder to access the following options:· OpenLaunches File Explorer focused in the currently highlight folder.
· Rename

Renames the folder and updates the references in the project.
· Addo Existing File...
Launches the file browser to select a file to add to the project.
o New File...
Launches the Add File dialog to add a new file to the project.
o New Folder...
Adds a new folder under the highlighted location.
o Add Git Ignore File
Creates a .gitingnore file to filter out any temporary project files (for Git source control).
· Remove

Removes the folder from the Project panel.
· Delete

Deletes the folder from the project directory and removes the folder from the Project panel.

Project File - Menu Options
Right-click on a file to access context sensitive options based on the file type:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

234

Panels· OpenOpens the file in the Editor or Designer.
· Rename

Renames the file and updates the references in the project.
· Debug Script File

Debugs the script.
· Run Script File

Runs the script.
· Run Script in Console

Runs the script in the console window.
· Preview Form

Displays the form the way it will appear at run time without executing any code.
· Remove

Removes the file from the Project panel.
· Delete

Deletes the file from the project directory and removes the file from the Project panel.
· Open with PowerShell HelpWriter

Opens the help file in PowerShell HelpWriter.
· Open with PrimalXML

Opens the XML file in PrimalXML.

8.11.1 Project Files and Folders
Using folders within projects makes it easier to organize projects with large amounts of files. This topic
shows you how to add 235 , rename 241 , move 242 , and delete 242 project files and folders.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved235

PanelsHover over a file to see the file path:

Adding Files and Folders
How to add an existing file
Click the Add Existing File

PowerShell Studio - Help Manual

button, select a file to add to the project, then click Open:© 2023 by SAPIEN Technologies Inc., all rights reserved

236

PanelsSelect Yes if you want to create a copy of the file in the project directory:

You can also drag and drop files and folders into the Project from a file directory. Simply click anddrag the desired file or folder, and then drop it in the project:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

237

PanelsSelect Yes if you want to create a copy of the file in the Project directory:

Dragging and dropping a folder into the Project panel will automatically create a copy of thefolder in the project directory.

How to add a new file
Click the New File

PowerShell Studio - Help Manual

button to launch the Add File dialog where you can select a file template:© 2023 by SAPIEN Technologies Inc., all rights reserved

238

Panels

The file templates are grouped into categories in the upper-left of the dialog. The PowerShell category lists all PowerShell script files, and the Forms sub-category contains the form templates:

The Files category at the top lists all of the templates:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

239

PanelsUse the search field to search the template titles and their tags:
Select Files to search all available templates regardless of category.

The small text located next to the template names are tags/keywords that describe the contentsof the particular template:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

240

Panels
The tags associated with the Full Grid Search template shown above indicate that this template is a
PowerShell script that has a GUI with a Grid and has Search capabilities.
Tags can also be used to filter out file templates by language.

Once you have selected a file template, enter a File Name, and then click Add to add the new file tothe project:

How to add a folder
Click the New Folder button to add a new folder:

Or, you can add a new folder by right-clicking and selecting Add > New Folder:

The new folder will be created under the location highlighted when the folder was added:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

241

PanelsDragging and dropping a folder into the Project panel will automatically create a copy of thefolder in the project directory.

Renaming Files and Folders
To rename files you must use the Project panel instead of File Explorer, otherwise the project'sreferences will point to incorrect paths.
You can rename files and folders by clicking twice on the file or folder name in the project panel, or
by right-clicking and selecting Rename:

Alternately, you can rename a folder in the Properties panel by highlighting the name and typing a
new name:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

242

PanelsFor more information on Properties, see Properties Panel 245 .

Moving Files and Folders
To move files you must use the Project panel instead of File Explorer, otherwise the project's references will point to incorrect paths.
You can move files and folders within the Project panel by clicking the icon next to the name anddragging > dropping:

Deleting Files and Folders
How to delete a file
Right-click and select Delete or press the < Delete > key:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

243

PanelsSelect Yes to delete the file:

The file is deleted, regardless of location:· If the file was copied into the Project, then the file will be deleted from the project directory.
· If the file was not copied into the Project, then the file will be deleted from the source location.

How to remove a folder from the Project panel
Highlight the folder and press the < Delete > key (or right-click and select Remove):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

244

Panels

The folder is removed from the Project panel:

The folder remains in the project directory:

How to remove a folder from the Project panel and delete it from the project directory
Right-click the folder and select Delete, then click Yes to confirm:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

245

Panels

The folder will be deleted from the project directory and from the Project panel.

8.12 Properties Panel
The Properties panel allows you to view and edit the control properties when working in the GUI
Designer, and edit project settings and project file settings when working in a project. This topic
provides an overview of the Properties panel and shows you how to work with events 248 .
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press P.

Properties Panel Overview
The Properties panel allows you to view and edit the properties of any object selected in the Forms
Designer 154 or the Project panel 230 .

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

246

PanelsGUI Designer Properties

Project File Properties

When you edit form controls in the Properties panel the changes are immediately reflected in the
Designer.
There are a number of controls at the top of the Properties panel:· Object Picker Dropdown

Allows you to switch between controls on a form:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

247

Panels· Properties - Sort Order Buttons

The pair of buttons on the left allow you to switch between viewing properties grouped into functional categories or listed alphabetically:· Properties and Events View Buttons

The pair of buttons in the middle allow you to switch between looking at the properties an object
supports or the events it can trigger:

Pressing F1 when a control property is selected will open the related MSDN Help topic in abrowser window:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

248

PanelsWorking with Events
Event handlers can be created using the Properties panel.
How to create an event handler
First select a control in the designer and access the Properties panel. Click on the lightning-bolt button to display the events that belong to the control.
If multiple controls or project files are selected, only common properties and events are displayed. If you assign a value to a property, it is applied to all selected objects. If you assign an eventto a control, the event will be assigned to all of the controls.
The following screenshot shows the events for a form. The Load event has been connected to ahandler called Mainform_Load:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

249

PanelsTo handle another event, simply double click in the blank cell next to the event:PowerShell Studio will create an event handler named $<object name>_<event name> and insert it in
the script at the caret position. For example, double-clicking in the blank cell next to FormClosing
results in the following code being generated:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

250

PanelsIf you want to specify the name of the event handler you can type its name rather than doubleclicking in the blank cell. PowerShell Studio will use the name you type to generate the event handler.

8.13 Snippets Panel
The Snippets panel allows you to view and manage preset and user-defined snippets (reusable text andcode). This topic provides information about the Snippets panel, and shows you how to manage snippets 252 and work with snippet folders 253 .
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press S.

Snippets Panel Overview
PowerShell Studio provides an extensive collection of snippets to help you complete common coding tasks quickly. Each snippet contains a block of code that can be easily added to a script.
Hover over a name in the Snippets panel to see the snippet Description and Shortcut:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

251

PanelsSnippets Panel - Buttons and Search
There are three buttons and a search box at the top of the Snippets panel:

From left to right:·

RefreshCauses PowerShell Studio to rescan the snippets folder and refresh the Snippets panel.

·

Open
Opens the currently selected snippets folder in File Explorer.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

252

Panels·New
Launches the Snippet Editor to create your own snippet. It is also possible to edit and delete an existing snippet by right-clicking and choosing edit or delete respectively.

·

SearchSearch for a snippet by typing the first few letters of a snippet in the search box. As you type,PrimalSense™ will give you a list of possible completions.

Managing Snippets
Right-click on a snippet to display the following options:· Insert

Use any of these options to add a snippet to a script. The snippet will be inserted at the current
caret position in the code Editor:o Right-click on a snippet and select Insert-ORo Double-click a snippet-ORClick the snippet and then press < Enter >-ORo Drag a snippet and drop it in the code Editor.
· EditOpens the snippet in the Snippet Editor 329 .
· Delete

Deletes the snippet.
You can drag-and-drop snippets within the Snippets panel.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

253

PanelsSnippet Folders
There are four snippet folders available in the following priority order: Project 253 , User 253 , Custom 254 , Preset 254 .
· Project

A 'Project' snippet folder will appear in the Snippets panel whenever you open a project:

You can copy snippets to and from the project by dragging the snippet within the Snippets panel:

A snippet can also be added to a project by creating or copying the snippet to the project's
file directory, and PowerShell Studio will automatically display it in the Snippets panel when you
open the project. It is not necessary to add the snippet to the project using the Project panel 230 .
· UserNew snippets that you create will automatically be stored in the 'User' folder unless you change
the folder path: %Users%\<user>\AppData\Roaming\SAPIEN\User Snippets\PowerShell:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

254

Panels

To modify an existing snippet, copy it into the 'User' folder.
· CustomYou can add a custom directory to the Snippets panel, such as a shared network snippet repository, via Home > Options > Panels. Specify the folder path in the Custom Directory field:

This folder is named ’Custom’ in the Snippets panel, regardless of the folder path selected:

After designating the custom directory folder path, you must refresh the Snippets panel toview the 'Custom' folder.
· Preset

The 'Preset' folder contains the snippets included with PowerShell Studio, and they are loaded
from the following folder: %ProgramData%\SAPIEN\PowerShell Studio <year>\Snippets.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

255

PanelsSnippet Folders - Context Menu Options
Right-click on a snippet folder to access the following options:· Expand / Collapse

Expand or Collapse the subfolders.
· OpenOpen the folder in File Explorer.
· Create Snippet

Create a snippet.
· Rename

Rename the folder.
· Delete

Delete the snippet folder and all of its contents.
· Create Folder

Add a subfolder.

8.14 Toolbox Panel
The Toolbox panel displays Windows Forms controls and control sets that can be used when designinga PowerShell form in the GUI Designer 154 .
· Controls are built in .NET controls.
· Control sets are custom controls built out of standard controls and custom scripts.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

256

PanelsKeyboard Shortcut
Press Ctrl + Alt + P, release, then press T.

Toolbox Panel - Buttons and Search
There are three buttons and a search box at the top of the Toolbox panel:

From left to right:·

Controls
Displays a list of controls that can be added to a form.

·

Control Sets
Displays a list of control sets that can be added to a form.

·

SelectDisplays the controls and control sets added to the current form that is open in the Forms
Designer.

·

SearchSearch for a control or control set by typing the first few letters in the search box. As you type,PrimalSense™ will give you a list of possible completions.

Controls and Control Sets
You must have a form open in the GUI Designer to activate the Controls and Control Sets options.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

257

PanelsControls

Control Sets

Control - Context Menu Options
Right-click on a control to display the following options:· Insert

Adds the control to the current form.
· View in Object Browser

Focuses the object browser on the .NET control type.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

258

Panels· MSDN Help

Launches MSDN Help for this control in a web browser.
· View Spotlight Article

Launches tutorial content for this control on the SAPIEN web site.

Control Set - Context Menu Options
Right-click on a control set to display the following option:· Insert

Adds the control to the current form.
There are three ways to add a control or control set to a form:· Drag and drop the control or control set on the form.
· Double-click the control or control set.
· Right-click on the control or control set, then select Insert.

Select Tool
The Select tab is on the top of the Toolbox panel, to the right of the Control Sets tab. Use the Selecttool to select a control, which selects the control in the Designer and displays the control properties:

Use Shift+Click or Ctrl+Click to select multiple controls. When multiple controls are selected, theProperties panel displays only the properties that the selected controls have in common.

Select Tool - Context Menu Options
Right-click on a control in the Select list to display the following options:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

259

Panels· Add Events...

Opens the Add Events dialog to select events to add to the control.
· Go to Event

Displays the events that are wired to the control. When clicked, it will go to the event in the Editor.
· Delete

Deletes the control from the form.
· Rename

Opens the Rename object dialog.
· View in Object Browser

Focuses the object browser on the .NET control type.
· MSDN Help

Launches MSDN Help for this control in a web browser.
· View Spotlight Article

Launches tutorial content for this control on the SAPIEN web site.
· Bring to Front

Sends the control to the top/front of the form.
· Send to Back

Sends the control to the bottom/back of the form.
Use the Bring to Front context menu option to send the control to the top of the form without
having to find the control in the Designer.

8.15 Tools Output Panel
The Tools Output panel displays output from external tools. When debugging, the Tools Output panel
displays breakpoint notifications and post mortem messages.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

260

PanelsKeyboard Shortcut
Press Ctrl + Alt + P, release, then press L.

Tools Output Panel Overview
The Tools Output panel displays output from any tool, such as the Universal Version Control system,
Custom Menu, or the PSScriptAnalyzer Module:

When debugging, breakpoint notification and the post mortem state of the variables are displayed:

Tools Output Panel - Context Menu Options
Right-click in the Tools Output panel to display the following options:· Copy (Ctrl+C)

Copy highlighted text to the clipboard.
· Copy HTML (Ctrl+Shift+C)

Copied highlight code, including color coding and formatting.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

261

Panels· Find (Ctrl+F)

Search the text in the output panel.
· Select All (Ctrl+A)

Select all of the text in the output panel.
· Clear (Ctrl+E)

Clear the output panel.

8.16 Variables Panel
The Variables panel lists all variables and values in the current scope during a breakpoint when debugging.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press V.

Variables Panel Overview
The Variables panel shows the current values of all PowerShell variables during a debugging session
at a breakpoint:

Variables Panel - Context Menu Options
Right-click in the Variables panel to display the following options:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

262

Panels· Add To Watch

Add the variable to the Watch panel 264 .
· Query in Debug Console

Display the variable details in the Debug Console panel during a debugging breakpoint.
· Clear Session Variables

Clear the Variables panel.
· Copy (Ctrl+C)

Copy the selected variable to the clipboard.

Variables - Filter and Search
How to filter and search for variables
Use the drop-down menu to show All variables, User variables, or PowerShell variables:· Show all variables

Displays all the variables in the current debug session.
· User variables only

Displays user defined variables only.
· PowerShell variables only

Displays the PowerShell built-in variables.

How to filter variables by name
Type the variable into the Search box:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

263

PanelsVariables - Object Properties
In addition to displaying the values of all variables, the Variables panel also lets you examine theproperties of objects.
How to expand the object properties
Double-click a variable name or click on the arrow (>) next to a variable name:How to expand the array values for a variable during a debugging breakpoint
Click the arrow (>) on the left-side of the variable row, or double-click anywhere on the variable row:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

264

Panels8.17 Watch Panel
The Watch panel displays the values of variables and expressions that you define when debugging.
Keyboard Shortcut
Press Ctrl + Alt + P, release, then press W.

Watch Panel Overview
The Watch panel allows you to choose the variables you want to monitor during debugging:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

265

PanelsWatch Panel - Context Menu Options
Right-click in the Watch panel to display the following options:· Copy (Ctrl+C)

Copy the selected item to the clipboard.
· Select All (Ctrl+A)

Select all fields and values in the Watch panel.
· Query in Debug Console

Display the watched item details in the Debug Console 210 during a debugging breakpoint.
· Remove Watch Item (Delete)

Clear the item from the Watch panel.
· Remove All

Clear all items from the Watch panel.

Using the Watch Panel
How to add a new variable to the Watch panel· Type its name in the next free slot in the Expression column.

-OR· Highlight the variable in your code, then right-click and select Add to Watch.

-OR· Highlight the variable in your code, then click to drag and drop the variable in the Watch panel.

You can also monitor the values of object properties or calculated expressions:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

266

Panels

Evaluating Expressions
The debugger can evaluate complex expressions to help you see what results your script is generating. To evaluate an expression while a script is paused, highlight the expression in the code window:

Drag the expression to the Watch panel. The expression is immediately evaluated and the result is
displayed. The expression will be re-evaluated each time a line of script is executed allowing you tocontinually view the expression's result.

Any number of expressions can be added to the list. To remove an expression, select it in the list andpress Delete.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

267

Projects
9Projects

PowerShell Studio projects facilitate the grouping of related files and settings. For example, a PowerShellutility might consist of several different Forms and Scripts. PowerShell Studio allows you to keep thesefiles together as a project, and then use the built-in packager to create an executable file which includes
everything in the package. Using a project instead of a single file script makes it easier to manage additional content, and allows you to organize your script into individual script files to make your code moremanageable.
Other valuable uses for projects include management of the development workflow. With PowerShell
Studio you can develop the project in a "sandbox" on your local machine, and then deploy the completed, tested, and debugged files as a single unit to a "live" production environment.

9.1

Project Templates

PowerShell Studio contains predefined templates for various project types.

9.1.1

Available Project TemplatesThis topic explains the project template options.

Project TemplatesCollection Project
A collection project template allows you to group and deploy independent script files in an organized manner. The group of files typically consist of, but are not limited to, ps1 script files. A collection project is useful when you have various ps1 scripts that dot source each other.

All files within the project are considered 'content'. There is no project entry point (Startup.pss - project startup script) because the project consists of individual files.
Learn more about creating a Collection project 273 .

Empty Project
The empty project template creates an empty project for a script application.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

268

Projects

The empty project template creates a basic project with an entry point. The empty project contains asingle file called Startup.pss that runs when your project is executed. Startup.pss contains a Mainfunction which serves as the entry point to the project / script, and is a good place do any preparatory work before calling other scripts in the project.

Form Project
The form project template is used to create a GUI script with additional scripts and files.

A form project contains three files:· Globals.ps1

A script file containing functions and variables that will be available throughout your project.
Anything you define in this script will become global to the project.
· MainForm.psf

An empty form in which you build the GUI for your script.
· Startup.pss

The script that runs when your project is executed. Startup.pss contains a Main function which
serves as the entry point to the project / script.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

269

Projects
Module ProjectA module project is used for creating a PowerShell script module. The module project template isuseful for creating packaged, reusable utilities that can be installed anywhere they are required.

A module project contains three files:· <ProjectName>.psd1 *The manifest file for your module.
· <ProjectName>.psm1 *The PowerShell script code for your module.
· Test-Module.ps1

The PowerShell script code for testing your module.
* The file names are the same as the project name.
Learn more about creating a Module project 276 .

Multi-Form Project
A multi-form project is the same as a form project with the addition of another form called
ChildForm.psf.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

270

Projects

Windows Service Project
A Windows Service project template allows you to create a Windows PowerShell service project, andis used for the service packaging engine.

9.1.2

Creating a ProjectThis topic shows you how to create a new project using the New Project template.

How to create a new project
To create a project
Select the File tab > New >New Project (Ctrl+Shift+N):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

271

Projects

You can go directly to some project templates from the File > New menu, such as New Form
Project or New Module Project.

Select a template in the New Project dialog:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

272

Projects

After selecting a template, complete the following information:· Project Name

A name for your project.
· Location

The folder to store your project files in.
The default location for project files is: %Users%\<user>/Documents\SAPIEN\PowerShell Studio\Projects>
This path can be changed in Home > Options > General > Directories > Default Project Directory:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

273

Projects· Create project folder

Select this option to store your project files in a new sub-folder in the 'Projects' folder. Uncheckthis option if you want to store your project file in an existing folder.
Checking Create Project Folder will ensure that your project files are stored in their own sub
directory in the 'Projects' folder, rather than mixing them together with files from other projects.
· Include Git ignore file for temporary project files

When checked, PowerShell Studio will create a .gitignore file for Git source control that filters any
temporary project files.
Next, click Create to create the project. PowerShell Studio will create all of the files specified in thetemplate and display them in the Project panel 230 .

9.1.3

Collection Project

The collection project allows you to group and deploy independent script files in an organized manner.

About Collection Projects
If you have various ps1 scripts that dot source each other, a Collection project will allow you to:· Manage multiple files.
· Leverage PrimalSense support for dot sourced files.
· Apply rename refactoring to all of your files.

When a Collection project is created there is no Startup.pss file; there is no entry point in the project
because the project conains individual files. All files within the project are considered 'content'.
You can run each file individually by right-clicking on a file in the Project panel, or from the ribbon(Home tab > Run menu > Run options):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

274

Projects

Collection Project Deployment
Deployment is handled on a project basis. You can deploy all the project files to a single destination
or create an install that includes all of the project files.

The collection project's Deployment properties are used to control the Packager, MSI, and Deployment behavior of the project as a whole, or as individual project files.
A collection project's packaging is restricted because the files are all individual.
To access the project's Deployment properties
Click on the collection project name in the Project panel 230 :PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

275

Projects

The project properties will display in the Properties panel 245 :Collection Project Deployment Properties· Deploy As

Determines the deployment behavior of the Project as a whole. There are two Deploy As options:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

276

Projects
File

The project will handle each file individually from a deployment perspective. Eachproject file will maintain its own independent settings.
When to use:
Use this setting when you are using the Collection Project to group individual files
that don't necessary interact with each other. With this setting, you can package
and deploy (publish) each script independently.

Project

The project will deploy all of the files as a whole. You must define a primary file forthe purposes of the Packager and MSI builder.
When to use:
Use this setting when you have a group of files that interact and have a start/entry
point script (i.e., a primary script that dot sources various secondary scripts). The
primary script will get converted into an executable, and you can create an installerthat includes the primary packaged script and all of the supporting files/scripts.
The project files are also deployed (published) as a whole.

· Primary File

Designates the primary file for the project (Deploy As = Project). The primary file will be the filethat is packaged into an executable, and all other files will be considered external content.

9.1.4

Module ProjectA script module is a library of PowerShell functions delivered together for some common purpose.
Script modules are a good way to create packaged, reusable utilities that can be installed anywhere they
are required.
The module project template includes everything that you need to get started:

The psm1 file is where you define the functions that implement your module. A psm1 file is just a
regular PowerShell script with a different extension. You add functions to the file in the same waythat you would create a regular ps1 script file.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

277

Projects
The psd1 file is a module manifest file. It is used to provide extra metadata about a module including
such things as:· Module version number.
· Author.
· Description.
· Prerequisites for executing the module: required PowerShell version, required CLR version, othermodules and assemblies that must be present.
· Export restrictions: lists of functions, variables, aliases and cmdlets to export.

Using a module manifest file allows you to cleanly separate your code from instructions andmetadata about your code.
You can add multiple psd1 and psm1 files to a module project as long as they are located in a
sub-directory and not in the root of the project folder.

The Test-Module.ps1 script lets you test the functions and other features of your module.
To use the Test-Module.ps1 test script· Import the module (be sure to import the correct version).
· Write commands that test the module features (you can include Pester tests).

To run the Test-Module.ps1 test script· From any script in the project, on the Home tab click Run, or click Run > Run in Console.

-OR· Right-click on the Test-Module.ps1 tab, then select Run Script or Run Script in Console.

-OR· In the Project panel 230 , right-click on the Test-Module.ps1 script, then select Run Script File or

Run Script in Console.

9.1.5

New Module from Functions

The New Module From Functions option allows you to import functions from various ps1 scripts andmerge them into a new script module.

How to create a New Module From Functions
Select the File tab > New > New Module From Functions:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

278

Projects

If a file is not already open, you will be prompted to select a file.
The Convert Functions into Module dialog allows you to select files and functions for the new module:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

279

Projects

Convert Functions into Module - Dialog Options· Module NameEnter the name you wish to give your new module.
· Location

Specify the folder where the module will be saved. The default is PowerShell Studio's project directory.
· Create Module Folder

This option creates a folder using the module's name and places all the generated files within thatfolder. This folder will be created in the folder specified by the Location field.
· Create external XML help file

This option will create an external XML help file for the module suing the imported functions.
· Include Git ignore file for temporary project files

When checked, PowerShell Studio will create a .gitignore file for Git source control that filters any
temporary project files.
· Source Files

Contains the list of files from which the selected functions will be extracted.
o Add File

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

280

Projects
Use the Add File button to add ps1 scripts to the Source Files, in order to extract their functions.
o Remove FileUse the Remove File button to remove unnecessary files from the Source Files list. This can help
de-clutter the functions list.
· Functions

The functions section contains a node for each file and a list of functions that are declared in eachfile. Select the functions to import into the new module:

You can check and un-check all the functions in the file by checking/un-checking the file's
node.
If a function references another function, it will have a Referenced Functions folder icon containing
a list of all the referenced functions:

When you check a function in the list that has references, it will automatically check all the referenced functions.
After you have selected the functions and configured the options in the Convert Functions into
Module dialog, click Create Module to generate the new module.
In some instances you may have a duplicate function that is defined in multiple files. PowerShell
Studio will compare these functions, and if they are identical it will only insert the function once. If
the functions are different, PowerShell Studio will automatically rename the duplicate. A warning will
be displayed in the Output panel when this occurs:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

281

Projects

The New Module From Functions project contains four files:· <ModuleName>.psd1

The manifest file for your module.
· <ModuleName>.psm1

A PowerShell script containing all of the imported functions.
· <ModuleName>.psm1-Help.xml

The PowerShell XML Help file for the module, generated using the imported functions.
· Test-Module.ps1

The PowerShell script code for testing your module.

9.2

Project Properties

Project properties are shown in the Properties panel.

How to view project properties
Click on the project name in the Project panel 230 :PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

282

Projects

The project properties will display in the Properties panel 245 :Project Level Properties· Projecto Project Name
Allows you to change the project name.
o Project Path
The location where the project is stored. This is not an editable property.
· Synchronizationo File Filter
The file filter used to synchronize the project files.
o Synchronized
Synchronize projects and files when the project is loaded.
This option allows you to trigger project file synchronization when the application regains focus(activated). In order for this feature to work, you must select Sync files when the application is
activated in Options > General > Project Settings:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

283

Projects

You also need to have a project open with file synchronization enabled (Synchronized = True):

Project sync on activate ensures that the application can detect changes when you are making modifications to the project's folder structure outside of PowerShell Studio.

9.3

Managing Project Files

Project files and folders are managed in the Project panel.
The top of the Project panel 230 has buttons for common project tasks, as well as a search box:

To access the project level options
Right-click on the project name:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Projects284

To access context sensitive options
Right-click on a project file or folder:
Project file options

Project folder options

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

285

Projects

9.4

Project File Properties

A project's file properties are shown in the Properties panel.

How to access the project file properties
Click on the project name in the Project panel 230 :The file properties will display in the Properties panel 245 :Project File Properties· Build

This property determines what PowerShell Studio does with a file when you deploy / export a project. Three options are supported:o Include
The file is included in the build. The Reference Function properties are used to help integrate thefile contents into the shell.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

286

Projectso Exclude
The file will not be included in the build.
o Content
The file will be included in the build but any code contained in the file will not be integrated into
the shell. This is a useful option when you want to include data files in your project.
· Build Order

Sets the order in which the file is built / merged by the project.
· File Path

The location where the file is stored. This is not an editable property.
· NameThe name of the file can be edited here.
· Reference Function

The name of the function that invokes the project file.
· SharedIf enabled, the functions and variables declared in the ps1 file can be referenced by other project
files, and you will not be able to invoke the file by its reference function.
· Export Function (Module projects only)

Exports the functions defined in the file. Requires the project's Auto Export Functions property to
be True.

Invoking Project FilesThe Reference Function property described above references the function that allows simple invocation of a project file. If you add a script file called Utilities.ps1 to a project and you examine its properties, you will see that PowerShell Studio has generated a Reference Function called Invoke-Utilities_ps1. You can use this name elsewhere in your project scripts to run the code in Utilities.ps1.
For Form projects, PowerShell Studio uses this method to load the first form in a project from the
project startup script (Startup.pss):

9.5

Adding Script Parameters to Projects

Adding a Param block to the Startup.pss file allows you to provide startup parameters to your project
when it runs.
The runtime behavior depends on how the project is started:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

287

Projects· If you start your project from the console, then you provide parameter values on the command

line, separated by spaces.
· If you are starting a Forms project, then PowerShell Studio will prompt you for the parameter val-ues.
· If you package a project into an EXE file, then you must always provide startup parameters on thecommand line.
You can also add Param blocks to forms and scripts in your project, as long as their Shared property
is not set to true. Simply add a Param block to the beginning of the file and provide parameter values when you invoke the file.
For example, if we wanted to pass the current user's name to each form in our script, we could add aParam block to each form:

Then supply an appropriate value when we call the form:

9.6

Running a Project

Options to run a project are available on the Home ribbon 140 , and also in the Project panel 230 .
To run a project· Click the Home tab > Run menu > Run (Ctrl+F5):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

288

Projects-OR· Right-click on the project name in the Project panel and choose one of the Run options:

The execution options available will depend on the project type.
You can also run each file individually by right-clicking on a file in the Project panel 230 .

9.7

Exporting a Project

Exporting a project converts the project into a single script file that contains all of your code, plus theauto-generated code produced by PowerShell Studio. You can export a project to a file, or to the clipboard.
The export options are located on the Deploy tab > Export section:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

289

Projects

Project Export - Options· Export to File

Exports the project to a ps1 file.
· Export to Clipboard

Copies the project to the clipboard.

9.8

Form Return Variables

In order to simplify working with forms in a project, PowerShell Studio will create special variables thatallow you to refer directly to a property of controls on a child form. These variables are accessible fromthe script that invokes the form's reference function (see Invoking Project Files 286 ).
To demonstrate this, create a new Multi-Form project (File > New > New Form Project > MultiForm Project):

The Multi-Form project template includes a button on the main form called 'Call Child Form'.
Click on the main form Script tab to view the code. Notice that the CallChildForm button click handler includes the Show-ChildForm_psf reference function to call the child form:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

290

Projects

Next, add a textbox to the child form (Child Form Designer tab > Toolbox panel > Textbox control):For information about Windows Forms controls, see Panels > Toolbox Panel 255 .
PowerShell Studio will make the text property of the textbox in the child form directly accessible inthe main form through a variable called $ChildForm_textbox1. The screenshot below shows PowerShell Studio's Intellisense suggestion when you type '$chi' in the main form:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

291

Projects

This example illustrates that you can access a child form variable in the the main form code.
These form return variables make it easy to gather the results from data entry forms.
The controls that support this mechanism are summarized below, along with the type of data thatthey return:PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

292

Projects
Control

Return Type Property and Data Type

Checkbox

Checked (Boolean)

CheckedListBox

Selected item (string)

ComboBox

Selected item (string)

DataGridView

SelectedCells (DataGridViewCellCollection)

DateTimePicker

Selected date (DateTime)

ListBoxCollection of selected items(string)

ListView

Collection of selected items(string)

MonthCalendar

Selected date (DateTime)

NumericUpDown

Selected value (Decimal)RadioButton

Checked (Boolean)

RichTextBox

Text (string)

Textbox

Text (string)

Tracker

Value (int)

Treeview

Selected Node (string)

9.9

Projects and Source Control

Projects can be managed as a unit through PowerShell Studio's source control integration.
Before managing a project through source control, source control integration must first be configured 305 .

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

293

Projects

To work with source control
In the Project panel 230 , right-click on the project name:· Add to source control

Adds the project to source control.
· Check in

Checks in one or more project files which have changed or not yet been checked in.
Individual files within the project can be checked in or out independently, but checking files in together as a project helps to simplify file and source control management.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

294

Packaging Scripts
10

Packaging Scripts

PowerShell Studio contains the Script Packager™, which can package single or multiple scripts, supporting files, and COM components into a single, standalone executable file (.exe).

10.1 Creating a Script Package
This topic shows you how to create a script package.
If this is your first package, begin by setting up the Script Packager 295 .
To create a package· Click Deploy on the ribbon, then in the Packager section click Build or Build & Run:o Build (Ctrl+F7) - Creates an executable file from the active documento Build & Run - Creates an executable file from the active document and executes it.

PowerShell Studio checks the syntax of the designated files and packages them into an executable
file (.exe).
If your build is successful, information about the new executable file is displayed in the Tools Output
panel:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

295

Packaging Scripts
10.2 Setting up the Script Packager
The Script Packager contains everything you need to customize your executable files and create a package.
To open Packager Settings and configure a script package
1. Click Deploy on the ribbon, then click Settings in the Packager section to open the Script Packager interface:

2. Select the desired settings in the Script Packager interface (see details below):· Script Engine 295· Output Settings 296· Restrictions 302· Version Information 303· Build Commands 303

Script Engine
Target Platform
The Script Packager provides four options for building executables:· Microsoft Windows 32 Bit will generate a 32 bit excecutable.
· Microsoft Windows 64 Bit will generate a 64 bit executable.
· Microsoft Windows 32 and 64 Bit will generate a 32 bit and a 64 bit executable.
· Microsoft Windows Native will create a starter executable which will launch the correct version de-pending on the current platform.
Select the desired platform from the options in the Target drop-down list:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

296

Packaging Scripts
Script Engines
Each script engine option provides a preview of what the selection will do:

Each package contains only one engine type. To include more than one script type in an executable file, create an MSI file.
STA Mode
Use STA Mode (Powershell
engines only)

STA (Single Threaded Apartment) Mode allows you to start yourscript in single threaded mode. This is essential when your script
uses forms to interact with the Windows GUI. Some GUI controls require STA mode in order for them to function correctly.

Output Settings
Output Settings Options
File name

Filename of the executable.

FolderFolder for the executable.
It is recommended that you leave the common folder default

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

297

Packaging Scripts
name of "bin" for consistency. Learn more 298 .
Icon file (optional)

A custom icon (.ico) for the executable.

Generate .config file

Generates a .config file.
If you select Windows Native, .config files will be generated for
all three of the .exe files.

Resolve and include external
scripts

The code of external scripts will get injected into the packaged
script when building the executable.
Enable this option to resolve dot sourced files while packaging.
Learn more 300 .

Hash file type

Options for the Hash file type: None, MD5, SHA1, SHA256.

Manifest creation

Options for the manifest file, including a custom manifest.
(This is an executable manifest, not a Windows PowerShell module manifest.)

Custom manifest

Opens a file to the specified line.

Alternate credentials

Uses the credentials of the specified user to run the scripts in theexecutable file. Learn more 300 .

Run mode

Current user: Runs scripts with the permissions of the user who
runs the executable file.
Impersonate user: Switches to the security context of the specified user, but uses the environment (e.g. network profiles,
mapped drives, environment variables) of the current user.
RunAs user: Runs scripts with the permissions of the specified
user in the specified user's environment.
Learn more about the Run Mode options 301 .

Signing

PowerShell Studio - Help Manual

Specify the code signing certificate to sign your executable. If
you specify a PFX file that requires a password, include it here.

© 2023 by SAPIEN Technologies Inc., all rights reserved

298

Packaging Scripts
The Timestamp URL creates a timestamp for the signature used
to sign the file, allowing the signature to remain valid even after
the certificate expires.

Engine Settings
The packaged executable files are generated in a platform specific folder under a common folder. It
is recommended that you leave the common folder default name of "bin" for consistency:

The build target you select will determine the platform specific folder that the packaged file(s) are
generated in:· 32 bit files will be in bin\x86· 64 bit files will be in bin\x64· 32 bit and 64 bit files will be in their respective folders (bin\x86 and bin\x64)

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

299

Packaging Scripts· Windows Native executables will be in bin\Any platform

Choosing the Windows Native option will generate three .exe files:
o <app>x86.exe and <app>x64.exe are your actual packaged script.
o <app>.exe is a starter application that will execute the right package for the current platform.
You must install or deploy all three files together for your application to work. The starter application
will receive the same icon, digital signature, and manifest as the packaged files, so a shortcut to<app>.exe will create the same experience.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

300

Packaging Scripts
If you select both Windows Native and Generate .config file, then .config files will be generated
for all three of the .exe files.

External Scripts
Select Resolve and include external scripts to deploy dot sourced files with the executable. If thisoption is enabled, the code of the external scripts will get injected into the packaged script whenbuilding the executable.
· Files specified with or without single and double quotes are supported. Files that do not exist will

issue a warning. If you have a dot source statement inside a comment block, the file will be inserted into the comment block.
· Using a line comment will prevent a file from being resolved.
· If you need to resolve only some but not all external files, you can use a different case for the fileextension:o ./include/lib.ps1 will be resolved by the packager.
o ./include/lib.PS1 will not be resolved.
In other words, the statement is case sensitive; the actual filename's case is not relevant.

Alternate Credentials
By default, the scripts in a package run in the security context of the user who runs the package. You
can specify alternate credentials (a username and password) that will be used to run the scripts.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

301

Packaging Scripts

The alternate credentials you supply must be available (either as local or domain accounts) on any
computer where the packaged executable will run. Also, the credentials must generally have local administrator privileges on the computer where the package will run.
Alternate Credentials options:· Username

Username of the specified user that will run the scripts in the package.
To specify a domain, use username@domainname format, not domain\user format. Do not
specify a domain or computer name for local accounts.
· Password

Password of the specified user that will run the scripts in the package.
· Run Mode

Select the user profile that will run the scripts in the package.
o Current user
Runs scripts with the security context of the current user, in the current user's environment.
o Impersonate user
Runs scripts with the security context of the specified user, in the current user's environment.
o RunAs user
Runs scripts with the security context of the specified user, in the specified user's environment
Elevate Regular User to Full Administrator
This section explains how to package a script as an executable, with the objective of allowing a regular user to accomplish a task that requires full administrator privileges.
Some background:
Since Windows Vista, the Administrator security token is split—you cannot simply logon as Admin
and do anything you need to do. An Admin must elevate in order to accomplish certain tasks (e.g.,when accessing or modifying certain system areas). This has ramifications for packaging executables—you cannot successfully use a run mode of RunAs or Impersonation, and also elevate at the sametime.
When selecting RunAs or Impersonation:· The specified credentials are stored inside the packaged executable, encrypted.
· When the packaged executable is launched, it uses certain API calls to create a new security token(Impersonation) or run itself with the specified credentials (RunAs). The executable needs to loadand execute in order for this to happen.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

302

Packaging Scripts
When selecting a manifest for elevation:· The manifest is embedded in the executable—unencrypted—because Windows needs to read thisinformation.
· Windows will load and evaluate this manifest before any code is executed. If you run this from a

regular user, you will be prompted for Admin credentials and also to verify elevation. The credentials stored inside the package have no effect at this point because they would only be applied
after the fact.
Essentially, due to the way Windows evaluates manifests, elevation happens before RunAs / Impersonation—but it needs to be the other way around to avoid prompts and to not give regular users
Admin privileges. The Script Packager accomplishes this via a two-step process:1. Starter.exe—a simple script packaged as an executable that includes; the Admin credentials, a runmode of either RunAs or Impersonation, and instructions to launch your script.
2. Your script—packaged as an executable, with a manifest for elevation.
Using this process, Starter.exe will launch and use the specified Admin credentials, and then yourscript will run with elevation.
Depending on your local settings, you may get a prompt to allow your script to modify yoursystem, but it will not prompt you for actual credentials.

Restrictions
Use the Restrictions to limit the environment in which the package runs.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

303

Packaging Scripts
When restricted to a specific version, the executables display the expected and encountered versions in the error message.

Version Information
Use the Version Information settings to specify characteristics of the current version of the executable file.
The version number must be in #.#.#.# format.

Build Commands
Use the Build Commands to define custom commands to run before or after packaging.
The commands will be executed in the sequence defined; one after the other, rather than in parallel.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

304

Packaging Scripts

Use the four buttons at the top-right of each section to manage the pre- and post-packaging commands:

From left to right:·

Add File - Browses for a file / exe.

·

Remove - Removes the command.

·Move Up - Moves the command up in the order.

·

Move Down - Moves the command down in the order.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

305

Source Control Integration
11

Source Control Integration

PowerShell Studio provides a number of source control options, including a Universal Version Control
system that integrates with command-line tools such as Git 305 , or integrating with a Microsoft Source
Code Control Integration (MS SCCI 308 ) software provider.

11.1 Universal Version Control
The Universal Version Control system allows configuration of any source control provider with command-line tools. The current support scope includes the Git source control system. Support will be expanded to include other providers.

Using Git
To enable Git support
Go to File > Options > Source Control. In the System drop-down list, select Git:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

306

Source Control Integration

To disable the Universal Version Control feature, select <Disabled> from the System dropdown.

Git Commands
Once enabled, the preconfigured Git commands will appear in the Source Control tab on the ribbon:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reservedSource Control Integration

307· InitInitialize a Git repository in the current folder.
· CloneCreate a clone of a remote repository.
· Add

Add a file to a repository.
· Add All

Add a file or all files in the folder to a repository.
· Commit

Commit a change to a repository.
· Commit All

Commit all changes to a repository.
· Status

Get the status of the current file.
· Status All

Get the status of the current file or all files in the folder.
· DiffShow the difference for the current file.
· ResetRewinds history (files + commits) back to the previous commits.
· Checkout

Switch branches or restore working tree files.
· Branch

Create a new branch.
· Merge

Merge the specified branch.
· PushUpload the local repository content to a remote repository.
· PullFetch and download content from a local repository.
· Tag

Create a tag for the current repository.
· Shell

Launch a Git command shell.
· GUI

Launch the Git GUI tool.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

308

Source Control Integration
You will be prompted if a value is required to execute the command. For example, when you selectthe Git Commit command, a commit message is required:Output from Git will be displayed in the Tools Output panel:

11.2 Microsoft Source Code Control Integration
Your source control software must either be VersionRecall from SAPIEN Technologies, or your source
control provider must provide an SSAPI-compatible client, such as Microsoft Visual Source Safe.

Configuring Source Control Integration
Before configuring PowerShell Studio for source control, you must install your source control
software's client.
To configure source control integration
Go to File > Options > Source Control:
1. Make sure that the Universal Version Control feature is <Disabled>.
2. Select Enable MS SCCI API source control.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

309

Source Control Integration

PowerShell Studio will automatically detect the presence of the source control client and automatically display it in the Providers list box. If your source control client does not appear, then shutdown
and restart PowerShell Studio.
Your source control provider must be displayed in the Provider list; if it is not, then source control is not properly installed and will not be available to PowerShell Studio.
After enabling source control you can configure the options however you like, including prompting
before checking files out, automatic check-in, and directing output messages:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

310

Source Control Integration

Source control settings are configured in Options and Settings > Source Control 377 .

Using Source Control
PowerShell Studio does not provide source control capability—it simply integrates with the features of your compatible source control software. Some features described here may not be available in your software, or may work somewhat differently.
Before a file can be managed through source control, it must first be added.
To add a file to source control· With the file open, on the Source Control tab > select Add To...:-OR· Right-click the file name tab and select Add To Source Control:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

311

Source Control Integration

You must first save unsaved scripts before they can be added. If you do not, PowerShell Studiowill prompt you to save the file first.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

312

Source Control Integration
Your source control software governs the add process and may prompt you for login credentials, a location for the script, or other information.
Once added, scripts can be checked in or out using the buttons on the Source Control ribbon:

Source control functions are also available on the file context menu:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reservedSource Control Integration

PowerShell Studio - Help Manual313© 2023 by SAPIEN Technologies Inc., all rights reserved

314

Source Control Integration
Source Control Commands
Some of these source control options may not be available, or may work differently, depending on
your source control provider:· Launch

Launches the source control software.
· Add To...

Add the current document to a source control database.
· Check In

Checks in the changes of the current document into the source control database.
· Check Out

Checks out the current document for editing from the source control database.
· Undo Check Out

Restores the file to the last checked in version.
· Get Latest

Get the latest version of the document from the source control database.
· View History

View the past versions of the current document.
· Properties

View the source control properties of the current document.
· CompareCompares the active document to a previous version.
· Refresh

Refresh the source control status.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

315

ScriptMerge
12

ScriptMerge

ScriptMerge is a stand-alone application shipped with PowerShell Studio that compares files and folders
and applies differences to either of the two compared items.

12.1 Running ScriptMerge
ScriptMerge can be started from the Windows Start Menu, or from within the PrimalScript and PowerShell Studio applications.
To start ScriptMerge from the Windows Start Menu
· In the Windows Start Menu, select SAPIEN Technologies, Inc. > ScriptMerge:

To start ScriptMerge from PrimalScript
1. In PrimalScript click the View tab > then in the Panels section, check the Tools box.
2. In the Tools Browser click SAPIEN Tools > then click the ScriptMerge icon.
To start ScriptMerge from PowerShell Studio· In PowerShell Studio, open two files to compare > then click Home > in the Edit section, click theCompare Files button:

12.2 Comparing Files
ScriptMerge compares files side-by-side and highlights the differences.
To compare files
Click File > Compare files:
1. In the Left File window, navigate to the folder.
2. Select a file in the Name window below.
3. In the Right File window, navigate to the folder.
4. Select the other file to compare in the Name window below.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

316

ScriptMerge
5. Click Compare Files.

When the files are first opened, ScriptMerge displays the differences as gray, light yellow, anddark yellow colored lines. The current difference—in this case the first difference—is highlighted
in varying shades of red:
· Light yellow indicates words that have changed.
· Dark yellow indicates a line that contains a change.
· Dark grey lines indicate a line that was deleted.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

317

ScriptMerge
To see the highlighting in action, change a line and save it. The changes will be reflected in thecomparison.
You can customize the comparison differences coloring in File > Settings > Merge Options >Color Options.
To step through the differences· In the Differences section, click Next and Previous to go back and forth through the differences:

The current difference is highlighted in different shades of red:

Click Highlight Diff to add extra emphasis to the changed elements for the current difference:

To merge the differences· In the Merge section, select Right or Left:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

318

ScriptMerge
12.3 Comparing Folders
ScriptMerge compares folders side-by-side and highlights the differences.
To compare folders
Click File > Compare folders:
1. In the Left Folder window, select a folder.
2. In the Right Folder window, select a folder.
3. Click Compare Folders.

ScriptMerge compares the files in each folder and their contents. The results show which folders
have files in both locations, or if the folders have files in only one location. If the folders have files
in both locations, ScriptMerge indicates if the files are different or identical.
Files that exist in both locations but are different are marked with a red whole page icon:

Files that are identical in both locations are marked with a blue whole page icon:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

319

ScriptMerge

Files that are only in one folder are marked with a blue half-page icon. The icons reflect the folder
location: left half-page icons are in the Left Folder; right half-page icons are in the Right Folder:

To replace a file in one folder with the file in the other folder· In the Merge section, select Right or Left.

-OR· Right-click the file and select Copy (Left to Right or Right to Left):

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

320

ScriptMerge

12.4 Comparing Groups
You can group pairs of files and then easily open the group to compare. This feature is useful for repeated comparison of the same files.
To create and open a group
1. Create a text file with the file pairs listed as follows:
File1|File2 separated by the pipe symbol ( | ).
Example: C:\Users\Me\Documents\SAPIEN\script1.ps1|C:\Users\Me\Documents\SAPIEN\script2.ps1
2. Save the file as <filename>.smgrp (smgrp = ScriptMerge Group):

3. Open the group file and ScriptMerge will open the contained pairs at the position of the first difference:· Double-click the group file.

-OR· In ScriptMerge select File > Compare group, then navigate to the group file location:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

321

ScriptMerge

12.5 Context Menu Options
The ScriptMerge context menu options will vary depending on if you are comparing files or folders.
To access the context menu options· Right-click on the file comparison or folder comparison tab:Compare Files - Context Menu

Compare Folders - Context Menu

· ClosePowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

322

ScriptMerge
Closes the highlighted tab.
· Close All

Closes all of the tabs.
· Close All but current

Closes all tabs except for the highlighted tab.
· Open containing folders (file comparison only)

Opens two Windows Explorer instances with the compared files selected.
· Compare containing folders (file comparison only)

Compares the files in each underlying folder, and also the file contents.
· Open compared folders (folder comparison only)

Opens two Windows Explorer instances, one for each compared folder.
· New Horizontal Tab GroupMoves the selected tab to a separate horizontal tab group.
· New Vertical Tab GroupMoves the selected tab to a separate vertical tab group.
· Move to Previous Tab GroupMoves the selected tab back to the original tab group.
Tab groups are especially useful when you have a folder comparison open and also a numberof files compared. Move the folder comparison to it's own tabbed group so that it remains visible
while you compare the files in the folders.

12.6 Navigating Between Differences
The Differences section of the ribbon provides buttons to help you move between differences in a fileor folder:· Next (Ctrl+Down)

Moves forward to the next difference.
· Previous (Ctrl+Up)

Moves back to the previous difference.
· First (Ctrl+H)

Moves to the first difference.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

323

ScriptMerge· Last (Ctrl+E)

Moves to the last difference.
· Current (Ctrl+Enter)

Scrolls the code window to the current difference.
· Highlight Diff

Adds extra emphasis to the changed elements in code files.

12.7 Reconciling Differences
The Merge section of the ribbon provides buttons to help you copy from one file or folder to another:· Right (Ctrl+Right)

Copies the current selection from the left to the right file or folder.
· Left (Ctrl+Left)

Copies the current selection from the right to the left file or folder.
· Right, Next Diff

Copies the current selection from the left to the right and advances to the next difference.
· Left, Next Diff

Copies the current selection from the right to the left and advances to the next difference.
· All Right

Copies all differences from the left to the right file or folder.
· All Left

Copies all differences from the right to the left file or folder.

12.8 Signing Scripts
ScriptMerge allows you to to handle digital signatures in your files.
You can re-sign scripts or remove signatures from the ribbon buttons:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

324

ScriptMerge· Sign Left

Sign the script file displayed on the left.
· Sign Right

Sign the script file displayed on the right.
· Sign BothSign both script files.
· Remove Left

Remove the signature from the script file displayed on the left.
· Remove Right

Remove the signature from the script file displayed on the right.
· Remove BothRemove the signatures from both script files.

12.9 ScriptMerge Settings
You can adjust some ScriptMerge tool settings, such as keyboard shortcuts and Quick Access Toolbar
buttons. You can also change the highlight colors for comparisons, and toggle some compare options.
To access the ScriptMerge options· Select File > Settings:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

ScriptMerge

325

The following settings can be adjusted:· General Optionso Sign script files when saving.
o Use last folders selected.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

ScriptMerge

326· Quick Access Toolbar

o Add, Remove, Reset toolbar buttons.
o Show Quick Access Toolbar below the Ribbon.
o Customize Keyboard Shortcuts.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

ScriptMerge

327· Merge Options

o Select comparison color options.
o Toggle compare options for Case, Whitespace, and Blank Lines.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

ScriptMerge

328

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

329

Snippet Editor
13

Snippet Editor

PowerShell Studio provides a collection of snippets to help you complete common coding tasks quickly.
You can use the Snippet Editor 329 to easily edit and create snippets.

About Snippets
Snippets are small pieces of reusable code that can be quickly inserted into your scripts, thus saving
you time and reducing errors. This piece, or "snippet" of code, can vary from a full-fledged function
to a simple single line statement. Snippets come in a variety of languages such VBScript, PowerShell,
C#, etc.
PrimalScript and PowerShell Studio come with extensive libraries of reusable code snippets. You canalso save any text or code block as a snippet to automate code development. Snippets can include
placeholders; PrimalScript and PowerShell Studio will prompt you to supply values for these when
you use the snippet.

Snippets Panel
Use the Snippets panel to access and manage snippets:

To access the Snippets panel:· On the Home ribbon, in the Windows section, select Snippets from the Panels drop-down menu.

-OR· Chorded keyboard shortcut: Press Ctrl+Alt+P, release, then press S

Snippet Editor
The Snippet Editor is a self-contained program within PrimalScript and PowerShell Studio that supports multiple programming languages. Using the Snippet Editor is a fast and easy way to edit existing snippets and to create your own.
The Snippet Editor will launch when you edit an existing snippet or create a new snippet:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

330

Snippet Editor

The Snippet Editor
Snippet Properties
The top section of the Snippet Editor allows you to enter the following snippet properties:· TitleThe name of the snippet.
· Shortcut

The text you need to type in the code editor to invoke the snippet.
· Description

A short description of the snippet explaining what it does.
· Author

The snippet author details.
· Help URL

A link to help information. This will be displayed in the code editor.
· Language

Set to ’powershell’ for snippets used in PowerShell Studio.
Set to the appropriate language for snippets used in PrimalScript.
· TypePowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

331

Snippet Editor
This setting defines how the snippet will be displayed in the code editor (inserted into the code, orsurrounding existing code). The options are:o Expansion
Select this if your snippet is intended to be simply inserted into code.
o Surrounds With
Select this if your snippet can surround existing code.
o BothSelect this if your snippet can be used both ways.
The selection you choose for the Type property will dictate the menu options available when you
insert the snippet in the code editor:· Insert Snippet…

Only displays snippets where the 'Type' property is defined as Expansion or Both.
· Surround With Snippet…

Only displays snippets where the 'Type' property is defined as Surrounds With or Both.
If you choose a 'Type' value of Surrounds With or Both you must include the $selected$
placeholder variable* somewhere in your snippet code body, otherwise you may overwrite user
code when your snippet is used:( * Refer to the Built-in Placeholder Variables 333 section below for more information about theplaceholder variables provided with the Snippet Editor.)

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

332

Snippet Editor

Snippet Windows
The tabs at the bottom of the Snippet Editor provide more configuration options for your snippets:· References

This section tells PrimalScript or PowerShell Studio what dependencies your snippet has. The assemblies you list here will be loaded into PrimalScript or PowerShell Studio when you use the snippet.
· Output

This section is not used for PowerShell snippets.
· Variable Details

Before you configure the variable details you must add a placeholder variable to a snippet:
1. Position your cursor in the snippet code editor where you want to insert a variable, then rightclick and select Add Variable:

2. Name the variable:

3. The variable will appear in the snippet as $<variable>$ (e.g., $condition$):PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

333

Snippet Editor

4. Configure additional variable properties:· ID

The variable name.
· Default

A default value if required.
· Function

Not used in PowerShell snippets.
· TypeNot used in PowerShell snippets.
· KindNot used in PowerShell snippets.
· EditableNot used in PowerShell snippets.
· ToolTip

Provides some text explaining the purpose of the variable. This helps the snippet user understand how to complete the snippet. PrimalScript or PowerShell Studio will display these tooltips as the user navigates between the placeholders in the code editor.
· Imports

This section is not used for PowerShell snippets.
Built-in Placeholder Variables
The Snippet Editor provides two built-in placeholder variables:· $selected$

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

334

Snippet Editor
Allows you to merge code from the code editor into your snippet when it is used. For example,
you could create a snippet called ExtractFunction containing this code:

Now you can highlight lines of code and use this snippet to refactor them into a reusable function.
· $end$Specifies where the cursor should be placed when a snippet is inserted into the code editor.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

335

Options and Settings
14

Options and Settings

The Options dialog contains all of the main configuration settings for PowerShell Studio. This section
provides an overview of the available settings.

14.1 Accessing the Options
There are a number of ways to access the PowerShell Studio program options from the ribbon.
To access the PowerShell Studio configuration options· On the View tab > in the Windows section, select Options:

The Windows section of the ribbon might be compressed on smaller screens, such as tablets.
-OR· Select the File tab > select Options:14.2 General
This topic covers the settings available in Options > General.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

336

Options and Settings

In this section· Settings 336

o Saving Settings 337· User Information 338· Directories 338· Project Settings 338

Settings· Show start page on startup

Enables or disables the Start page 19 .
· Restore open files on startup

Reopens the files that were open when PowerShell Studio was last shut down.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

337

Options and Settings· Allow multiple instances

Allows for more than one copy of PowerShell Studio running at once.
· Enable deferred file loading

Loads files on demand. Deferred loading improves overall performance when loading large
groups of files while reducing memory consumption and load times.
· Update changed files automatically

Automatically reloads files that are modified externally. PowerShell Studio will still prompt if the file
has any unsaved changes.
· Enable remote file status check

PowerShell Studio will warn you if a file has been edited outside of its editor. Checking remote files
can cause PowerShell Studio to slow down. This option allows you disable remote file checking if
needed.
· Show exported files in Windows Explorer

After exporting files from PowerShell Studio, launch Windows Explorer focused on the export
folder.
· Show the document selector when navigating tabs

Controls the behavior of navigating between documents (Ctrl+Tab).
o Enabled
Cycle between documents using the Document Selector. The documents are displayed in activation order instead of tab order.
o Disabled
Cycle through the document tabs without opening the Document Selector.
· Default file type

Choose the default file type when a new document is created. Choose from PowerShell Script or
Form.
Saving Settings
There are three buttons at the bottom of the Settings section that control the saving and loading ofPowerShell Studio settings:

These settings can be used to back-up or load your settings, and they can also be shared with others for standardization purposes.
· Save All Settings...

This button saves all application settings, and it is recommended that you regularly export the settings. By default, the settings are saved to:Documents\SAPIEN\PowerShell Studio\Files\PowerShellStudio.Settings.xml· Save Editor Settings

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

338

Options and Settings
This button saves only the editor settings. By default, the settings are saved to:Documents\SAPIEN\PowerShell Studio\Files\PowerShellStudio.Editor.Settings.xml· Load Settings...

This button loads settings that were previously saved.

You will need to restart PowerShell Studio for the changes to take effect.

User Information· UsernameEnter the user name. This information will be used in your templates.
· Organization

Enter the organization name. This information will be used in your templates.

Directories· Default Files DirectorySpecifies the folders where scripts are saved.
· Default Project DirectorySpecifies the folders where projects are saved.
· Template DirectorySpecifies the folders where user templates are saved.

Project Settings· Default action for copy import file to project

When importing an existing file into a project, PowerShell Studio can make a copy of the file andadd it to the project folder or create a link to the original file.
o Ask

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

339

Options and Settings
Ask to copy import file.
o CopyAutomatically copy import file.
o Never
Never copy import file.
· Sync files when the application is activated

Allows you to trigger project file synchronization when the application regains focus (activated).
You also need to have a project open with file synchronization enabled (Synchronized = True):

Project sync on activate ensures that the application can detect changes when you are making
modifications to the project's folder structure outside of PowerShell Studio.

14.3 Backup
This topic covers the settings available in Options > Backup.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

340

Options and Settings

In this section· Editor Backup 340· Restore Points 341· VersionRecall 341

Editor Backup· Auto save every [ ] minutes

The frequency in minutes that files will be auto-saved.
· Enable file recovery

Activates the File Recovery system to recover modified files when the application is restarted after
an unexpected closure.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

341

Options and Settings
Changes are not committed for recovered files until the user explicitly saves the modified document.

Restore Points· Create a restore point as soon as a file is modified

Create a restore point when you modify a file to allow you to easily undo all changes. The automatic restore point is only created once, at the time of first edit (start of a session). When you create a permanent restore point, it only stores one. This is meant as a quick recovery tool and not asa versioning tool. So if you work on your script for a long time and you need to restore it to apoint using this method, then it will restore back to the beginning of your session. You will lose
everything you've done since.
If you are about to do something in the script that you may want to rollback, on the Source
Control tab > in the Restore Points section, click Create.
· Remove restore points when the application closes

When you close PowerShell Studio, restore points will be removed.

VersionRecall· Automatically submit to VersionRecall repository when a file is closed

VersionRecall is SAPIEN's version control system. This option allows you to save your script to VersionRecall when it closes.
For information, visit the VersionRecall product page.

14.4 Console
This topic covers the settings available in Options > Console. These settings allow you to configure theconsole style and manage embedded shells.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Options and Settings

342

In this section· Console Style 342· Consoles 343

Console Style· Font

Sets the Console font type.
· SizeSets the Console font size.
· BoldSets the Console font as bold.
· Italic

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

343

Options and Settings
Sets the Console font as italic.
· Enable enhanced console input line

Creates a separate input box to type in, instead of typing directly into the console.

To make your console style changes effective, click anywhere outside of the Options dialog or
the Console panel.

ConsolesOn the first run, PowerShell Studio will attempt to detect Windows PowerShell and PowerShell Coreand automatically add them to the Console list.

There are three buttons at the top-right of the Consoles list:

From left to right:··

Add Shell
Navigate to the shell executable and then click Open to add a shell.
RemovePowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

344

Options and Settings
Remove the selected shell.
·

Reset
Restore the default PowerShell consoles.
You must restart PowerShell Studio to apply the changes.

If you install a new version of PowerShell Core, you will need to reset your consoles to see thenew version in the console panel. If you don't want to reset any custom settings, then you will needto manually update the path to the PowerShell Core executable by clicking the three dots (...) to theright of the shell path.

14.5 Debugger
This topic covers the settings available in Options > Debugger.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

345

Options and Settings

Remote Ports
These settings configure the network ports that PowerShell Studio uses to connect to a remote installation of the Remote Script Execution Engine 379 (RSEE). You must use the same port numbers on
any computer that you want to support the remote execution. When deciding on which ports to use,
it is important to consult your network and security teams, as they will be able to advise you whichports are safe to use and, if required, reconfigure any firewalls. Port numbers are specified in the registry on a machine that is running the RSEE service.
The key is HKEY_LOCAL_MACHINE\Software\Policies\SAPIEN. The Value name is InPort (for the incoming port) and OutPort (for the outgoing port). These values are most easily configured bymeans of a Group Policy Object (GPO), and we provide a template (ADM file) that can be imported
into a GPO to configure RSEE.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Options and Settings

346

14.6 Designer
This topic covers the settings available in Options > Designer.

In this section· Designer Settings 346· Control Settings 347· Export 347· Source Files 348

Designer Settings· Layout Mode

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

347

Options and Settings
Governs how controls are aligned when added to the forms designer.
o SnapLines
Allows you to precisely align controls. As you move a control around on a form, snap lines willappear that show how the control aligns with its neighbors.
o SnapToGrid
Aligns controls to a grid overlaid on the forms designer.
§ Show Grid

Show or hide the grid.
o Grid Size
Increase or decrease the grid size.

Control Settings· Sync event names with control

Event handler names are generated using the pattern $<control name>_<event name>. This option ensures that when you rename a control its event handlers are also renamed.
· Sync controlnames with text

Event handler names are generated using the pattern $<control name>_<event name>. This option ensures that when you rename a control its event handlers are also renamed.
· Automatically insert default events

Many controls have a default event (click for a button, selected index changed for a ComboBox).
This option will ensure that the default event is always connected to an event handler when you
add a control to a form.
· Insert TODO comments in events

When enabled, PowerShell Studio will add a comment to each event handler reminding you toprovide your code body.
· Insert end of event comments

Adds a comment at the end of each event handler.
· Insert control helper functions

Uncheck this option to prevent PowerShell Studio from inserting control helper functions into thescriptExport· Embed Recovery Data in Exported Scripts

Enabling this option allows PowerShell Studio to add extra metadata to an exported script that allows it to recreate the original project or form (psf) that was used to create the export. The recovery data is stored in multi-line comment blocks in the exported script.
· Enable PowerShell V2 assembly compatibility

This setting determines the .NET assembly version used:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

348

Options and Settingso Enabled
2.0 .NET assembly references will be used when generating GUI scripts, and a warning will be
generated if any assembly does not support the .NET 2.0 Runtime.
o Disabled
4.0 .NET or later assemblies will be used, and a #requires -Version comment will be placed at the
top of the generated script.

Source Files· Default action for source file loads

This setting controls how PowerShell Studio loads exported scripts.
There are three options:o LoadReloads the original files that were used to create the exported script.
o Ignore
Loads the exported script as is.
o AskDisplays a dialog asking if the exported file should be loaded.

If the file contains recovery data you will also get a second prompt asking if you wish to use
the recovery data to reconstruct the original files:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

349

Options and Settings· Default action for source file searchThis option controls how PowerShell Studio responds when it cannot find the original files for an
exported script.
There are three options:o Search
Tries to locate the missing files.
o Never
Does not attempt to locate the missing files.
o Ask
Displays a dialog asking the user how to proceed.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

350

Options and Settings
14.7 Editor
These topics cover the settings available in Options > Editor. These settings allow you to customize theappearance of the script editor 48 , designate external assemblies 359 , and also control code formatting 360 and PrimalSense 369 behavior.
These options customize the appearance of the code editor panel.

In this section· Editor Settings 351

o Font and Color... 352§ Syntax Coloring 358· Auto-Insert 359· Analysis 359

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

351

Options and Settings
Editor Settings· Enable automatic syntax checking

Provides real-time syntax analysis as you type.
· Enable current line highlighting

Places a colored bar under the current line to provide a visual contrast.
· Use whitespaces instead of tabs

Inserts spaces rather than tabs into code when indenting.
· Show cmdlet help while typing

If you type a cmdlet it will appear in the Object Browser.
· Enable bracket highlighting

Highlights the opening and closing brackets when you click on either.
· Enable word wrap

Allows word wrap.
· Enable code folding

Allows script blocks, functions, comments, and regions to be collapsed to a single line in the code
editor.
For more information, see Script Editor > Manipulating Regions 51 .
· Enable track changes

Annotates the source code with yellow and green bars to indicate changes made in the current
editing session.
· Show line numbers

Displays line numbers in the left margin of the code editor.
· Show white spaces

Show white spaces that trail behind the back-tick at the end of a line.
· Collapse regions on load

Collapse the Include nodes when a script is loaded (configure Include nodes at Home > Edit > Regions > Include).
· Enable automatice reference highlighting

Automatically highlight the references of the current selection or the object under the caret. Automatically highlight the relevant object-based references when caret position is changed.
· Column

Specifies the column position where the column guide should be displayed. Show column guidemust be enabled.
· Show column guide

Displays a vertical line at a particular column.
· Tab size

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

352

Options and SettingsSpecifies the tab size.
· Insert comment-based help

There are two options:o Before Function
Inserts the comment right before the function declaration.
o Inside Function
Inserts the comment within the function declaration, before the parameter block.
For more information, see Script Editor > Comment-Based Help 112 .
Font and Color...
The Editor Font and Color Settings dialog allows you to customize the font and coloring of PowerShell Studio's editor, including syntax coloring for supported languages.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

353

Options and Settings· Presets

Predefined font and color themes are available from the drop-down list at the top of the dialog.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

354

Options and Settings

There are six default preset options:o (Saved Settings)
Restores the settings to the last saved state.
o Dark Theme
Changes the color scheme and font to a dark colored theme.
o Light Theme
Changes the color scheme and font to a light colored theme.
o PowerShell ISE Theme
Changes the color scheme and font to match the default settings of the Microsoft PowerShell
ISE.
o PowerShell Studio (Classic) Theme
Changes the color scheme to the default PowerShell Studio coloring and font.
o PrimalScript Theme
Changes the color scheme to the default PrimalScript coloring and font.
To select a preset
1. Select an option from the Presets drop-down; PowerShell Studio will update the font and color
settings to the predefined preset.
2. Click OK to apply the selected theme, and PowerShell Studio will use the new coloring.
· Save As Preset...

Saves your custom font and color settings as a preset.
To save a preset
1. Configure the font and color settings, and then click the Save As Preset… button:

2. In the Save Editor Style dialog, enter a name for the preset, and then click Save:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

355

Options and Settings

The custom preset will be displayed in the Presets drop-down list:

To import a preset
Copy the preset file (*.preset) to the following user specific folder:
C:\Users\<username>\AppData\Roaming\SAPIEN\PowerShell Studio\Editor Presets\
The imported preset will appear in the drop-down list the next time you edit the font and colors.
Share your custom presets with colleagues by sending them your preset file (*.preset).
· Font

Sets the editor font. All bolded fonts are fixed-width fonts.
· SizeSets the editor font size.
· Editor background

Sets the color for the editor background.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

356

Options and Settings

To define a custom color
1. Click the color picker drop-down and select the Custom tab.
2. Right-click on any empty color space:

The Color editor allows you to manually enter RGB values or use sliders to customize and selectthe desired color:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

357

Options and Settings· Modified line saved color

Sets the color for modified lines that have been saved.

· Modified line unsaved color

Sets the color for modified lines that have not been saved.

· Indicator margin background

Designates the background color of the indicator margin where the breakpoints, tracepoints, andbookmarks are located.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

358

Options and Settings· Current line indicator color

Sets the color for the current line indicator.
· Column guide color

Sets the color for the column guide.

Syntax Coloring
Designates theme coloring and style for supported languages and file types. This feature is very
helpful when working with a variety of file types; for example, when working with module projects.
· Language

Select the language or file type.
· Display items

Items available that can have their displayed color or style changed.
· Item foreground

Sets the color for the selected item foreground. The arrow to the right of the color selector dropdown will reset the color to (Automatic).
· Item background

Sets the color for the selected item background.
To set the background transparent for the selected item, click the Reset to Automatic arrow to
the right of the color selector drop-down:· BoldSets the selected item to display as bold.
· Italic

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

359

Options and Settings
Sets the selected item to display as italicized.
· Underline

Sets the selected item to display as underlined.
· Restore Defaults

Resets the language colors back to the default color settings (light theme).

Auto-Insert· Auto-insert closing parenthesis

Auto-completes parenthesis while you type.
· Auto-insert closing square brackets

Auto-completes square brackets while you type.
· Auto-insert closing curly braces

Auto-completes curly braces while you type.
· Auto-insert closing string quotes

Auto-completes string quotes while you type.
· Auto-insert import commands for used modules

When you type a cmdlet that is part of a module that isn't imported in the script, PowerShell Studio will automatically insert the Import-Module statement.
· Resolve functions when running a selection

Bypasses the requirement to include the function definition in the selection when using the Run
Selection command. In a Project context, PowerShell Studio will also automatically resolve functions defined in other project files.
This option only applies to Run Selection and not to Run Selection in Console.

Analysis· Automatically analyze scripts on run

Trigger PSScriptAnalyzer every time you run / debug a PowerShell script or a Project. The analysis
is displayed in the Tools Output panel.
Requires installation of the PSScriptAnalyzer module.

14.7.1 Assemblies
This topic covers the settings available in Options > Editor > Assemblies.
The Default Editor Assemblies page lists external assemblies that you explicitly designate to load
every time PowerShell Studio is started.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

360

Options and Settings
PowerShell Studio provides PrimalSense support for base .NET assemblies such as mscorlib, system.data, etc., and also ensures that the System.Windows.Form assembly is loaded (when running
GUI scripts)—without explicitly listing the assemblies in the Default Editor Assemblies page.

GUI psf files created with older versions of PowerShell Studio (2017 and earlier) will retain the oldassemblies list.

14.7.2 FormattingThis topic covers the settings available in Options > Editor > Formatting.
PowerShell Studio's code formatting is customizable to fit your needs:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

361

Options and Settings

Triggers
The first few options serve as triggers for auto-formatting. These options tell PowerShell Studiowhen to format your script:

The following triggers can be enabled:· Automatically format statement on new line

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

362

Options and Settings
Formats the line when you press <Enter>. You might not notice anything if the text is alreadyformatted.
· Automatically format completed block on }Formats a code block when the closing curly bracket is typed.
· Automatically indent new lines

Automatically indents the appropriate tab depth when inserting a new line by pressing <Enter>.
· Automatically format statement on ;Formats the statement when the semi-colon is typed.
· Automatically format on paste

Formats code when it is pasted into the script.

Formatting
The second set of options allows you to customize the formatting rules of PowerShell Studio:

Most settings shown below will be altered in the preview pane when changed, allowing you to
see what effect they have on your script.
The following formatting rules can be configured:· Place open brace on a new line

Places new open curly braces on a new line.
EnabledPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

363

Options and Settings

Disabled· Place statement keyword on a new line

Places each statement key word on a new line, such as the if and the else in an if/else statement.
Enabled (Place open brace on a new line = Disabled)

Disabled (Place open brace on a new line = Disabled)· Insert new line after Parameter attribute

Places each parameter attribute on its own line.
EnabledPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

364

Options and Settings

Disabled· Align parameter arguments on line continue

When parameter arguments are continued to a new line using the back tick line continuation character, they are aligned on the same column.
EnabledDisabled· Align hashtable equal signs

Aligns hashtable equal signs on separate lines.
EnabledPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

365

Options and Settings
Disabled

Only equalizes spacing for the first key value pair on any given line.

· Leave block on the same line

The script block stays on the same line.
Enabled (Place open brace on a new line = Disabled)

Disabled (Place open brace on a new line = Disabled)· Insert new line after Parameter type

Inserts a new line after the type of the parameter.
EnabledPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

366

Options and Settings
Disabled· Automatically expand aliases

Expands command and parameter aliases.
EnabledDisabled· Convert blog characters (curly quotes & dashes)

Replaces curly quotes (blog quotes) with straight quotes, and replaces extended dashes with endashes.
EnabledDisabled· Reserved Word Formatting

Formats reserved word (keyword) character casing.
o NoneLeaves the reserved word casing as is.
o Upper
Uses all upper-case characters:IF
IFELSEWHILEo Lower

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

367

Options and Settings
Uses all lower-case characters:
if
ifelsewhile
o CamelUses all camel case characters:
If
IfElseWhile· Parameter line spacing (0 disabled)

Governs the line spacing between parameters. If set to a value greater than zero, the specified
number of new lines will be inserted after the parameter.
Enabled (spacing = 2)

Disabled (spacing = 0)

· Parameter block indent

The number of tab spaces a parameter block will be indented.
Enabled (indent = 1)

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

368

Options and Settings

Disabled (indent = 0)

· Attribute parameter indent

The number of tab spaces an attribute parameter will be indented. This setting is used when 'Alignattribute parameters' is disabled.
Enabled (indent = 1)

Disabled (indent = 0)

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

369

Options and Settings· Align attribute parameters

Vertically aligns a parameter's attributes declarations. When disabled, the 'Attribute parameter indent' value is used to indent the subsequent lines of attributes.
EnabledDisabled (Attribute parameter indent = 2)

14.7.3 PrimalSense™
This topic covers the settings available in Options > Editor > PrimalSense™.
These options allow you to configure the behavior of PrimalSense.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

370

Options and Settings

PrimalSense Settings· Autocomplete on exact match only

Governs PrimalSense's selection and matching behavior.
o Enabled
Double-clicking or using the <Tab> key will auto-complete the item if the search expression is acomplete match (fully selected).
o Disabled
Using the <Space> key will trigger auto-completion of a partial match (partially selected).
· Show external tools in PrimalSense

Displays command line tools within PrimalSense's autocomplete list (the tools are cached).
· Show snippet shortcuts in PrimalSense

While typing, PrimalSense will list snippet shortcuts along with their command names.
· Show parameter set info after command

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

371

Options and Settings
When typing a space after a command, a pop-up window is displayed allowing you to cycle
through the command's parameter sets.
· Show command aliases in PrimalSense

When typing a command, PrimalSense will suggest aliases.
· Show parameter aliases in PrimalSense

When you type or specify the parameter in a command, PrimalSense will suggest aliases.
· Enable custom PrimalSense

Allows customized PrimalSense derived from a static list or from a dynamically created list using aPowerShell script.
· Enable word completion while typing

Fills in the missing characters on partially typed words (after typing three or more characters). The
drop-down list may provide one or multiple possible completions.
· Show .NET object descriptions

PrimalSense will display help text when you hover over an object.
· Enable snippet shortcut tab expansion

Pressing tab at the end of a snippet will expand it into the full name.
· Enable dot sourcing PrimalSense

When you dot source a file in PowerShell Studio, the file will be automatically loaded and parsed
to provide PrimalSense and coloring for functions contained in the file.
· Enable alias tab expansion

Pressing tab at the end of an alias will expand it into the full name.
· Sort parameters alphabetically

Disable this to display common command parameters at the end of the PrimalSense list.
· Query Session Assemblies

Loads the debug session's assemblies to provide syntax coloring and PrimalSense, when at a
breakpoint.
· Cmdlet PrimalSense

There are three options:o Show and Color All Cmdlets
Enables PrimalSense to show all cmdlets whether they are loaded or not.
o Show Cmdlets (Active Modules Only)
PrimalSense will only show cmdlets that are part of the current project.
o Show All Cmdlets (PrimalSense Only)
PrimalSense will offer suggestions from all of the PowerShell modules on your system.

14.8 Panels
This topic covers the settings available in Options > Panels.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

Options and Settings

372

In this section· Ribbon 372· Panel Layout 373· Auto Layout 373· Database Browser 373· Snippet Browser 374

Ribbon· Reset Quick Access Toolbar

Resets the Quick Access Toolbar to its default state.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

373

Options and Settings
Panel Layout· Automatically show output panels when text is displayed

Display output panels when text is displayed.
When a panel has new output, the panel's tab will highlight when it is docked or auto-hidden.
· Reload Previous State

Resets PowerShell Studio to the same state as the last time you opened it.
· Reset to Default State

Configures PowerShell Studio to its default panel layouts.

Auto Layout· Enable Auto Layout

Allows PowerShell Studio to arrange and display panels based on the current context. For example, when debugging, all of the debug related panels will be visible and all other panels will behidden.
· Editor Layout

Designates your preferred layout for editing code. Choosing (Current) will keep the layout you are
currently using.
· Designer Layout

Designates your preferred layout for designing forms. Choosing (Current) will keep the layout you
are currently using.
· Debugging Layout

Designates your preferred layout for debugging. Choosing (Current) will keep the layout you are
currently using.

Database Browser· Show schemas

This setting configures how the Object Browser 218 displays schema information from SQL server:o Disabled
The Object Browser will ignore schema information and display database tables, stored procedures, etc. in a simple flat list.
o Enabled
The Object Browser will display database objects in their respective schemas.
· Cache all fields

This setting will cache everything within the Database Browser 223 for quick loading of recently
used information. Checking this option will increase the time for the Database Browser to cacheand load the database.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

374

Options and Settings
Snippet Browser· Custom Directory

Adds an extra folder to the Snippets panel 250 .
Provide a network path here to create a shared snippet repository.

14.9 PowerShell
This topic covers the settings available in Options > PowerShell.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

375

Options and Settings
PowerShell Settings· Enable execution policy warning

PowerShell Studio will warn you if the current PowerShell execution policy is set to Restricted, andwill help you to change it if required.
· Update cache on module export

Updates the stored cache when exporting modules.

Windows PowerShell Security· Change Execution Policy

Allows you to reconfigure the execution policy for both 32-bit and 64-bit shells from a simple GUI
interface.
· Certificate in local store

The name of the certificate that PowerShell Studio will use for code signing.
· Password

The password required to access the certificate stored in PFX format.
· Time Stamp URL

Used to add a timestamp to the signature block in a script. This provides an extra level of security,
enabling PowerShell to determine if the certificates used to sign a script were valid when the script
was signed.
· External Signing Tool

Provides the name of an alternative code signing tool.
o Automatically sign .ps1 script when saving
Ensures that all scripts are signed.

14.10 Source Control
This topic covers the settings available in Options > Source Control, which allow you to configuresource control systems and providers.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

376

Options and Settings

Universal Version Control System
The Universal Version Control system allows configuration of any source control provider with command line tools.
· System

The source control system / provider.
o Disable
Disables the Universal Version Control feature.
o GitEnables version control support using Git.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

377

Options and Settings
MS SCCI API Systems· Enable MS SCCI API source control

Allows PowerShell Studio to use source control if it is available.
· Prompt for check In

This option works in conjunction with Automatic check in:
Prompt for Check In

Automatic Check In

Behavior

CheckedCheck In when a file is closed.

User is prompted tocheck in files.

Unchecked

Check In when a file is closed.

PowerShell Studio automatically checks in files.

Any value

Disable Automatic Check In.

User must manuallycheck files in.

· Automatic check inThis controls Check In behavior and has the following two options:o Disable Automatic Check In
Let's you decide when files should be checked in.
o Check In when a file is closed
Automates the check in process.
· Check out on edit

This controls Check Out behavior and has the following three options:o Automatically Check Out
PowerShell Studio will check a file out as soon as you edit the file.
o Prompt For Check Out
PowerShell Studio will display a file chooser dialog in which you can choose the files you wish tocheck out. The file you are currently attempting to edit will automatically be selected.
· Direct info output

This controls where output messages are directed, and has the following three options:o Suppress info messages
Hides all messages.
o Write to output panel
Messages are displayed in the Output Panel.
o Display in message box
Messages are displayed in a pop-up dialog.
· Providers

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

378

Options and Settings
Displays the list of available source control providers and allows the user to switch between them.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

379

Remote Script Execution Engine
15

Remote Script Execution Engine

The Remote Script Execution Engine™ (RSEE™) is an enterprise-level remote script execution environment.

RSEE Overview
RSEE consists of two components: The client, which is built into PrimalScript and PowerShell Studio,
and a remote service that must be deployed to each computer where you will remotely run scripts.
RSEE is capable of deploying a script from within PrimalScript and PowerShell Studio, out to remotecomputers where the script is executed, and bringing the scripts' output and results back to PrimalScript or PowerShell Studio for your review.
RSEE is a complex tool and it interacts closely with Windows' security subsystems. RSEE is recommended for use only by experienced Windows administrators who fully understand service deployment and management, cross-computer security and authentication and, in the case of domain environments, Group Policy objects and Active Directory administration. Apart from the guidelines inthis manual, SAPIEN Technologies cannot assist you with security issues caused by improper configuration nor can we assist with Active Directory, Group Policy, or local computer configuration tasks.
RSEE is designed only for Windows Script Host (WSH) scripts in VBS (VBScript) or JS (JScript) files. It
is not designed for other WSH scripts (including WSFs) nor is it designed for scripts written in otherlanguages (such as batch, KiXtart, and so forth).

RSEE Deployment
RSEE's service component is packaged in a Microsoft Windows Installer (MSI) file and is suitablefor deployment via Group Policy. You can also manually install it on individual machines. Keep inmind that, once installed, the service needs to be started in order to be useful. This will occur automatically after restarting the computer on which the service is installed (the service is set to start
automatically by default).
After deploying the service, there are a number of configuration steps that you must take in order toproperly configure RSEE in your environment.

Identity
RSEE installs, by default, to log in under the privileged LocalSystem account. This may be sufficientfor your purposes. However, when deploying scripts in PrimalScript and PowerShell Studio, be sure
not to specify any credentials in the Launch dialog box. Also be advised that the LocalSystem account may not be able to execute some scripts, depending on their security requirements.
We recommend that you configure the RSEE service to run under a user account that has administrative privileges on the local computer. In a workgroup environment this would be a local account,
and we recommend creating the same local account (with the same password) on all of your com-

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

380

Remote Script Execution Engine
puters, for consistency. In a domain environment, we recommend creating a single domain accountwhich has local administrative rights on all computers in the domain, and using this account to run
the RSEE service. Whenever the RSEE service is running under a user account, you must specify that
account (and its password) when deploying scripts in PrimalScript.
When using RSEE, you have the option to specify the credentials under which the script should execute. Generally speaking, you need to provide the same credentials that the RSEE service is using tolog on.

TCP Port
The RSEE service defaults to using TCP port 9987 for incoming connections, and TCP port 9988 foroutgoing connections. It is your responsibility to ensure that any local firewalls will permit incoming
traffic on this port. Keep in mind that the Windows Firewall (Windows XP SP 2 and later, and Windows Server 2003 SP 1 and later) can be centrally configured via a domain Group Policy object.
To specify a different port
· You can specify a different port via the registry key HKEY_LOCAL_MACHINE\Soft-ware\Policies\SAPIEN. The Value name is InPort (for the incoming port) and OutPort (for the outgoing port). Note that these values are most easily configured by means of a Group Policy object(GPO), and we provide a template (ADM file) that can be imported into a GPO to configure RSEE.
The RSEE service and both PrimalScript and PowerShell Studio (as the RSEE client) utilize InPort and
OutPort. The service listens to InPort for incoming connections and uses OutPort to send script output back to the client. The client reverses this: scripts are sent via InPort and results are received on
OutPort. The registry key above configures these ports for both clients and the service.

Domain Tips
While manually configuring a few computers in a workgroup is not a hardship, manually configuring
an entire domain of computers can be burdensome. An Active Directory domain environment
provides a number of capabilities for centralizing and automating this configuration, however. While
this section is not intended as a comprehensive tutorial in Active Directory (we recommend that you
consult an experienced Active Directory administrator or the appropriate documentation if you needmore assistance), the following tips should help you configure RSEE more easily:· Create a domain accountName this account something like "RSEEUser" and provide it with a strong password per your organization's password policies.
· Deploy the RSEE service

This can be done by means of a Group Policy object (GPO) linked to the appropriate levels in thedomain. The RSEE service defaults to running under the LocalSystem account and it defaults toport 9987. The service's MSI is located in the RSEE folder under your PrimalScript Enterprise install-

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

381

Remote Script Execution Engine
ation folder.
· Make the RSEE service account a local Administrator

You can do this in a Group Policy object (GPO). Browse to Computer Configuration > Security Settings > Restricted Groups. Add a group ("Administrators") and then add your RSEE domain account (and any other appropriate accounts) to the group.
· Configure the RSEE service

You need to configure the RSEE service to log on with the user account (and password) you created. This can either be done manually or using a script. The book Windows Administrator's Automation Toolkit, for example, contains a script that can set the logon account and password usedby services running on multiple computers. Utilities like Service Explorer (www.scriptlogic.com) can
perform the same task.
· Select the TCP port

We provide a Group Policy object (GPO) administrative template (ADM file) that you can import
into a GPO and use to centrally configure the TCP port used by the RSEE service. This ADM file islocated in the RSEE folder under your PrimalScript Enterprise installation folder.

Using RSEERSEE now supports Powershell. To deploy the current script (only VBS and JS files are currently supported) to one or more remote computers that have the RSEE service installed, click the RSEE buttonon the Script toolbar, or select Run Script on Remote Computer from the Script menu.
RSEE performs a quick scan of your script to look for commands that might create a graphical user
element such as the VBScript MsgBox() function. If it finds any of these functions, it displays a warning message. Keep in mind that scripts will not normally be able to interact with the desktop environment on remote computers, meaning there would be no way for someone to respond to graphical elements such as MsgBox() or InputBox(). As a result, these elements can cause the script to"hang" and stop responding. RSEE does not perform an exhaustive check for graphical elements; itis your responsibility to ensure they're not used in your scripts. RSEE will allow you to continue withgraphical elements because you may have configured the RSEE service to interact with the desktopof the remote computer. It's your decision.
RSEE Launch dialog
The Launch dialog lists the computers where your script will be deployed. Note that the Launch dialog always preloads a default list of computer names at startup. Here's what you can do:· Click Launch to run the script on the computers which have a checkmark next to their name.
· Set or clear the checkbox next to one or more computer names. You can leave names in the list

but clearing their checkbox will prevent RSEE from attempting to run the script on them.
· Click Close to close the Launch dialog. If you've changed the list of computer names, you'll beprompted to save your changes.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

382

Remote Script Execution Engine· Use Load List and Save List to load an alternate list of computer names (from a text file) or savethe current list to a text file. By default, PrimalScript will look for a text file called Default.clt in the\SAPIEN\RSEE Lists folder under your Documents folder. You will need to create the file yourself if
you want a pre-loaded list when you launch RSEE.
· Use Select All and Unselect All to set or clear the checkbox next to all computer names currently inthe list.
· Select a computer name and click Remove to remove it from the list.
· Type a computer name (must be resolvable to an IP address by your computer) or IP address andclick + to add that computer to the list.
· Specify a username (user ID) and password. These will be used to run the script on the remotecomputer, and should generally match the username that the remote RSEE service is using to log
in. Note: if the username you specify is a local account on the remote computer(s), then just typethe username. If the username is a domain account, specify the name in the format user@domain.
The older domain\user format is not supported.
When you click Launch, RSEE will execute the script on the remote computer(s). Any output produced by the script will be displayed in the Output pane within PrimalScript or PowerShell Studio.
Note that the message "Socket connection failed" indicates that RSEE was unable to connect to the
RSEE service on a specified computer (either because the computer is not connected to the network,
has a firewall blocking the RSEE service ports, or the RSEE service is not installed).
RSEE deploys scripts asynchronously. That is, RSEE sends the scripts out to the remote computers
you've selected and then displays whatever results come back. If your scripts produce no output
then you won't see any results in PrimalScript or PowerShell Studio.
It's possible for the RSEE service on a remote computer to run into a problem (particularly securityrelated ones) that it can't report back; in these instances, it will seem to you (looking at PrimalScript
or PowerShell Studio) as if nothing has happened. Whenever possible, your scripts should incorporate error-checking and -trapping, and should produce appropriate output so that you get some results back if the script executes correctly.
Note that RSEE cannot be used to deploy a script for later execution. If you need to schedule a script
to execute on a remote computer at a particular time, use Windows' built-in Task Scheduler insteadof RSEE. You can even write a script utilizing the SCHTASKS.EXE command line tool that creates remote scheduled tasks on multiple computers.
Also note that, if an Output pane is already open in PrimalScript or PowerShell Studio, RSEE will utilize it rather than creating a new one. You will need to manually select the tab to view any RSEE results or error messages.

RSEE Restrictions
In order to bring the output of remote scripts back to your computer, the remote RSEE service cap-

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

383

Remote Script Execution Engine
tures the standard command-line output of your scripts. That means any script output must be created using the WScript.Echo method. Do not use graphical user interface functions such as MsgBox()
or InputBox(). Because the RSEE service doesn't interact with the desktop, nobody will ever see thesefunctions' dialog boxes and the script will hang.
It is possible, if the RSEE service is running under the LocalSystem account, to configure Windows toallow the service to interact with the desktop. You may wish to experiment with this configuration,
but it is not a recommended configuration because of the usual security restrictions on the LocalSystem account.
Also avoid any object methods-such as WScript.Popup-that create graphical elements.
Any objects referenced by a script must be installed, registered, and available on the remote machine where RSEE executes the script.
At this time, RSEE can only be used to execute Windows Script Host scripts. RSEE explicitly launches
scripts under CScript.exe which must be available on the remote computers.
Most other restrictions in RSEE are actually Windows security restrictions. When the RSEE service
launches, it does so using the credentials you configure in Windows' service manager. When the
RSEE service receives a script, it creates a brand-new process using whatever credentials you enter
into the RSEE Launch dialog. The following figure illustrates this process and the three sets of credentials involved:

RSEE Credentials and Execution Process
Always bear in mind that your scripts execute under the security credentials you provide (Credentials#2 in the diagram). This process does require your attention, as several things can go wrong if you're
not careful:· If you specify credentials in the Launch dialog (#2 in the diagram) that the RSEE service account(#3 in the diagram) doesn't have permission to use in a new process launch, then script execution
will fail.
Practically speaking, the credentials you provide in the Launch dialog (#2 in the diagram) need to be
the same as the credentials the RSEE service uses to log in (#3 in the diagram).
· If the RSEE service account (#3 in the diagram) doesn't have appropriate rights (including "Log on

as a service"), then the RSEE service will not be able to start.
· If your script tries to do something that the Launch credentials (#2 in the diagram) don't have per-mission to do—such as log into a database or access a file share—then you'll receive an error.
Depending on the exact situation, this may or may not be communicated back to you in Prim-

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved384

Remote Script Execution Engine
alScript or PowerShell Studio.
· If your script tries to perform an illegal operation—such as specifying alternate credentials in a

WMI connection (which is illegal because the script is executing locally on the remote machine, andlocal connections to WMI aren't allowed to use alternate credentials)—you'll receive an error.
Again, depending on the exact circumstances, this error may or may not be fed back to you inPrimalScript or PowerShell Studio.
These and other similar situations are not problems with RSEE; they are inherent conditions of theWindows operating system and its security subsystems. Whenever you encounter an error with
RSEE, bear these conditions in mind and think about the possible security ramifications of what yourscript is trying to do.

RSEE Notes
RSEE encrypts scripts during transmission to help keep them secure.
RSEE does not implement any sort of IP filtering capability (which might, for example, allow you toensure that only your computer can utilize RSEE on remote servers). Instead, we recommend using
Windows' own built-in IP filtering (available as part of Windows' IPSec features). Using this filtering,
you can ensure that only specified IP addresses are allowed to communicate on the TCP ports usedby the RSEE service, thus restricting who can contact that service and utilize RSEE.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

385

Reference
16

Reference

This section provides an overview of the SAPIEN Updates tool, and lists the keyboard shortcuts available
in PowerShell Studio.

16.1 SAPIEN Updates
We are continually updating our software, both to remove bugs and to add and improve product features. We recommend always staying current with the most recent versions to ensure that you are taking
advantage of the latest features, functionality, and product stability.
Every SAPIEN product has a built-in update tool—SAPIEN Updates—which will check for updates on all
current activations and unexpired trial versions of our products. Available product updates are indicatedin the SAPIEN Updates tool and also in the Notifications dialog 385 (see below).

SAPIEN Notifications
SAPIEN products provide automatic notifications when there is a software update available, or whenyour maintenance is about to expire. Notifications are indicated by a 'flag' icon in the top-right ofthe program window:

How to view SAPIEN notifications· Click the notification flag icon above the ribbon to open the Notifications dialog:· If a product update is available, click the update notification to open the SAPIEN Updates tool.

Click the X button to dismiss individual notifications or select Dismiss All. Dismissed notifications will not be shown again.

SAPIEN Updates - Tool Overview
The SAPIEN Updates tool indicates when an update is available for any SAPIEN program installed onyour computer.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

386

Reference
To minimize the impact on your system, the tool does not run during Windows startup or continuously in the system tray.
How to access the SAPIEN Updates tool
· On the Help or Tools ribbon > click Check Now or Check For Updates (Updates section).

-OR· Click the notification icon 385 above the ribbon > then in the Notifications dialog, click the up-

date notification.

SAPIEN Updates Tool

SAPIEN Updates Tool

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

387

Reference
SAPIEN Updates - Options
Check for updates now

Immediately checks to see if additional productupdates are available.

View Downloads folder

Displays the Downloads folder in File Explorer.

View update history

Displays the history of all downloaded and installed product updates.

Available

Displays a selectable list of available productupdates.
Select one or more products to Download
or Download and Install.

Download and Install

Downloads and installs the updates for the
product(s) selected in the Available updates list.

Download only

Downloads the updates for the product(s) selected in the Available updates list.

Close

Closes the SAPIEN Updates tool.

Notes

Displays a brief synopsis of what was changed,
added, or fixed for the products selected in the
Available window.
The build history for all SAPIEN products isavailable here.

Update On-Demand
You don't need to wait to be notified when an update is available; you can check for updates at any
time. This is particularly useful if you've heard about a new update and want to install it immediately,or if you are ready to start a new project and want to complete all updates before you begin.
How to check for updates on-demand· On the Help or Tools ribbon > select Check Now or Check For Updates to open the SAPIEN

Updates tool.
These instructions may vary between SAPIEN products.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

388

Reference· In the SAPIEN Updates tool, select Check for updates now:

The latest product updates are displayed in the SAPIEN Updates Available window.

Security and Permissions
Installing updates to programs in a Program Files directory requires the permissions of a member ofthe Administrators group on the computer. When you click Download and Install in the SAPIEN Updates tool, or if you install after downloading, you will be prompted for administrator credentials.
The update tool requires a functioning internet connection and unimpeded access through your internet firewall. For some installations, you might need to create a firewall rule to allow access or
make some accommodations.

16.2 Keyboard Shortcuts
This section covers the keyboard shortcuts available in PowerShell Studio.

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

389

Reference
General Commands
Copy

Ctrl + C

Paste

Ctrl + V

Cut

Ctrl + X

Select All

Ctrl + A

DeleteDel

Undo

Ctrl + Z

Redo

Ctrl + Y

New File

Ctrl + N

New Project

Ctrl + Shift + N

Open File

Ctrl + O

Open Project

Ctrl + Shift + O

Save

Ctrl + S

Save All

Ctrl + Shift + S

Print

Ctrl + P

Help

F1

Switch to Next Document Tab

Ctrl + Tab

Switch to Prev Document Tab

Ctrl + Shift + Tab

Minimize Ribbon

Ctrl + F1

Access Ribbon Key Shortcuts

Alt

Find in Files

Ctrl + Shift + F

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

390

Reference
Document Commands
Build All

F7

Build Package

Ctrl + F7

Build MSI

Shift + F7

Deploy Files

Ctrl + Shift + F7

Preview Form

Ctrl + Shift + F5

Debug

F5

Run

Ctrl + F5

Run Remote

F6

Run Remote RSEE

Shift + F6

Stop Script

Shift + F5

Run in Console

Ctrl + F8

Run Selection

Shift + F8

Run Selection in Console

F8

Format Script

Ctrl + Shift + J

Navigation Commands
Navigate Backward

Ctrl + Shift + Minus

Navigate Forward

Ctrl + Shift + Plus

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

391

Reference
Debugging Commands
Debug Document

F5

Debug with Multiple Files

Ctrl + M

Debug Remote (RSEE)

Ctrl + F6

ResumeF5

Step Into

F11

Step Over

F10

Step Out

Shift + F11

Run to Cursor

Ctrl + F10

Toggle Breakpoint

F9

Delete all Breakpoints

Ctrl + Shift + F9

Toggle Breakpoint Enable / Disable

Shift + F9

Toggle Tracepoint

Ctrl + F9

Delete all Tracepoints

Ctrl + Shift + Alt + F9

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

392

Reference
Designer Commands
Switch between Design and Editor

Ctrl + D

Move UpUp Arrow

Move Left

Left Arrow

Move Right

Right Arrow

Move Down

Down Arrow

Nudge Up

Ctrl + Up Arrow

Nudge Left

Ctrl + Left Arrow

Nudge Right

Ctrl + Right Arrow

Nudge Down

Ctrl + Down Arrow

Height Increase

Shift + Up Arrow

Height Decrease

Shift + Down Arrow

Width Increase

Shift + Right Arrow

Width Decrease

Shift + Left Arrow

Nudge Height Increase

Ctrl + Shift + Up Arrow

Nudge Height Decrease

Ctrl + Shift + Down Arrow

Nudge Width Increase

Ctrl + Shift + Right Arrow

Nudge Width Decrease

Ctrl + Shift + Left Arrow

Bring to Front

Ctrl + B

Send to Back

Ctrl + Shift + B

CancelEscapeReverse Cancel

Shift + Escape

Add Default Action EventEnter

Add EventCtrl + E

Apply Style

Ctrl + L

Create Style

Ctrl + Shift + L

Create Control Set

Ctrl + T

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

393

Reference
Editor Commands
Go To Line

Ctrl + G

Find / Replace

Ctrl + F

Find / Replace

Ctrl + H

Find Next

F3

Find Previous

Shift + F3

Find Selection Next

Ctrl + F3

Find Selection Previous

Ctrl + Shift + F3

Find All References

Ctrl + Alt + F

Comment Line

Ctrl + Q

Comment Multiline

Ctrl + Shift + Alt + Q

Un-Comment Line

Ctrl + Shift + Q

Go To Next Bookmark

F2

Go To Previous Bookmark

Shift + F2

Toggle Bookmark

Ctrl + F2

Clear All Bookmarks

Shift + Ctrl + F2

Toggle Collapsed Code

Ctrl + Shift + M

Collapse All Code Nodes

Ctrl + Minus

Expand All Code Nodes

Ctrl + Plus

Create Region

Ctrl + R

Copy as HTML

Ctrl + Shift + C

Wrap the selected text in () (parentheses)

Ctrl + Shift + 9

Wrap the selected text in [] (square brackets)

Ctrl + [Wrap the selected text in {} (curly braces)

Ctrl + Shift + [Wrap the selected text in '' (single quotes)

Ctrl + 'Wrap the selected text in "" (double quotes)

Ctrl + Shift + 'Wrap the selected text in $() (sub-expression)

Ctrl + Shift + Alt + 9

Toggle string quotes

Ctrl + Alt + 'PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

394

Reference

Return Commands
Insert Line BreakEnter

Insert Line Break

Shift + Enter

Open Line Above

Ctrl + Enter

Open Line Below

Ctrl + Shift + Enter

Delete / Backspace Commands
DeleteDel

Delete Line

Ctrl + Shift + L

Delete To Next Word

Ctrl + Del

Backspace

Backspace

Backspace

Shift + Backspace

Backspace To Previous Word

Ctrl + Backspace

Clipboard / Undo Commands
Copy To Clipboard

Ctrl + C

Copy To Clipboard

Ctrl + Ins

Cut Line To Clipboard

Ctrl + L

Cut To Clipboard

Ctrl + X

Cut To Clipboard

Shift + Del

Paste From Clipboard

Ctrl + V

Paste From Clipboard

Shift + Ins

Undo

Ctrl + Z

Redo

Ctrl + Y

Redo

Ctrl + Shift + Z

Movement Commands
Move Down

Down

Move UpUpPowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

395

ReferenceMove Left

Left

Move Right

Right

Move To Previous Word

Ctrl + Left

Move To Next Word

Ctrl + Right

Move To Line Start

Home

Move To Line End

End

Move To Document Start

Ctrl + Home

Move To Document End

Ctrl + End

Move Page Up

Page Up

Move Page Down

Page Down

Move To Visible Top

Ctrl + Page Up

Move To Visible Bottom

Ctrl + Page Down

Move To Matching Bracket

Ctrl + ]Move To Next Modified Line

Ctrl + Shift + Down

Move To Previous Modified Line

Ctrl + Shift + Up

Go To Next Occurance

Ctrl + Shift + Alt + Down

Go To Previous Occurance

Ctrl + Shift + Alt + Up

Go To Last Edit Position

Ctrl + E

Go To Function Declaration

F12

Go To Next Function

Shift + F12

Go To Prev Function

Ctrl + Shift + F12

Scroll Commands
Scroll Down

Ctrl + Down

Scroll Up

Ctrl + Up

Indenting Commands
IndentTab

IndentAlt + Right

Outdent

Shift + Tab

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

396

Reference
Outdent

Alt + Left

Selection Commands
Select Down

Shift + Down

Select Up

Shift + Up

Select Left

Shift + Left

Select Right

Shift + Right

Select To Previous Word

Ctrl + Shift + Left

Select To Next Word

Ctrl + Shift + Right

Select To Line Start

Shift + Home

Select To Line End

Shift + End

Select To Document Start

Ctrl + Shift + Home

Select To Document End

Ctrl + Shift + End

Select Page Up

Shift + Page Up

Select Page Down

Shift + Page Down

Select To Visible Top

Ctrl + Shift + Page Up

Select To Visible Bottom

Ctrl + Shift + Page Down

Select All

Ctrl + A

Select Word

Ctrl + W

Cut Word

Ctrl + Shift + W

Select To Matching Bracket

Ctrl + Shift + ]Select Block Down

Shift + Alt + Down

Select Block Up

Shift + Alt + Up

Select Block Left

Shift + Alt + Left

Select Block Right

Shift + Alt + Right

Select Block To Previous Word

Ctrl + Shift + Alt + Left

Select Block To Next Word

Ctrl + Shift + Alt + Right

PrimalSense™ Commands
PrimalSense™ Complete Word

PowerShell Studio - Help ManualCtrl + Space© 2023 by SAPIEN Technologies Inc., all rights reserved

397

ReferencePrimalSense™ Show Method Parameter Info

Ctrl + Shift + Space

Trigger Custom PrimalSense™ Keyword

Ctrl + Alt + P

Other Commands
Change Character Casing (to uppercase)Ctrl + Shift + U

Change Character Casing (to lowercase)Ctrl + U

Collapse Selection

EscapeToggle Overwrite Mode

InsertTranspose Characters

Ctrl + T

Transpose Words

Ctrl + Shift + T

Transpose Lines

Ctrl + Shift + Alt + T

Expand All Alias to Cmdlets

Ctrl + Shift + A

Toggle Alias

Ctrl + B

Insert Snippet

Ctrl + KSurround With Snippet

Ctrl + Shift + K

Expand Snippet Shortcut

Ctrl + J

Insert New Function

Ctrl + Shift + E

Edit Function

Ctrl + Shift + Alt + E

Rename Object

Ctrl + Alt + J

Edit Script Parameters

Ctrl + Shift + P

Qualify cmdlet Names

Ctrl + Shift + H

Unqualify cmdlet Names

Ctrl + Alt + H

Splat Command

Ctrl + Alt + S

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

398

Reference
Go-to-Panel Commands
Call Stack

Ctrl + Alt + P, K

ConsoleCtrl + Alt + P, C

Debug Console

Ctrl + Alt + P, D

File Browser

Ctrl + Alt + P, I

Find Results

Ctrl + Alt + P, R

Function Explorer

Ctrl + Alt + P, F

Help

Ctrl + Alt + P, H

Object Browser

Ctrl + Alt + P, B

OutputCtrl + Alt + P, O

Performance

Ctrl + Alt + P, M

Project

Ctrl + Alt + P, J

Properties

Ctrl + Alt + P, P

Snippets

Ctrl + Alt + P, S

ToolboxCtrl + Alt + P, T

Tools Output

Ctrl + Alt + P, L

Variables

Ctrl + Alt + P, V

Watch

Ctrl + Alt + P, W

Editor / Document

Ctrl + Alt + P, E

16.3 Appendices
Appendices for PowerShell Studio Help Manual
Appendix A: Manual and Product Version 399
Appendix B: Icon License Attribution 399

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved

399

Reference
16.3.1 Appendix A: Manual Version
Appendix A
Manual Version

This help manual is in the process of being updated. Some features and images in this manual version
may not reflect the current product functionality.
Blog articles
For the latest product tips and feature demonstrations, check out the PowerShell Studio articles on the
SAPIEN blog.
Release details
To view a brief description of what was changed, added, or fixed in the most recent PowerShell Studiobuilds, view the product version history.
Need more help?
Please direct your product related questions to the PowerShell Studio support forum, and your scripting
questions to the appropriate Scripting Answers forum.

16.3.2 Appendix B: Icon License Attribution
Appendix B
Icon License Attribution

Some of the icons used in this manual were made by Freepik at www.flaticon.com and are licensed under CC BY 3.0:

PowerShell Studio - Help Manual© 2023 by SAPIEN Technologies Inc., all rights reserved