PowerShell Studio: File Templates
- Written by David Corrales
- Last Updated: 21 April 2016
- Created: 22 May 2014
- Hits: 5319
Creating a Template
To create a template you can create a new file or simply open an existing template or file. Then use the Create Template option in the Ribbon’s file menu:
Then you are asked to save the file template:
Template files are simple text files that are located in the following user folder:
C:\Users\<username>\AppData\Roaming\SAPIEN\PowerShell Studio 2014\File Templates
The file 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.
If you are using a GUI form (psf file), it will take you to the usual GUI template dialog instead:
GUI forms are handled differently and require additional information when creating a template.
PowerShell Studio supports the following template variables that automatically expand when a template is loaded:
|%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 i.e. 2014|
|%Date%||Current Date i.e. 5/12/2014|
|%Time%||Current Time i.e. 2:17 PM|
|%FileName%||Inserts the file’s name. This will be empty for new non-project files.|
|%ProjectName%||Inserts the file’s project name.|
|%GUID%||Inserts a unique GUID.|
In addition to preserving your changes, PowerShell Studio allows you to define more then one template per file type, where as in the previous versions you could only modify the preset template. For instance, a user who works as a contractor may require unique templates for specific clients. Now the user can create dedicated templates for each of his clients and every time a new file is opened, the user will be presented with a list of available templates:
Note: The template list will only appear if there is more then one template defined for a specific file type.
PowerShell Studio - making it easier for you to customize the IDE to fit your specific needs.