PowerShell Command
In this article
Overview
You can use PowerShell Command Snap to execute the PowerShell commands.
Snap Type
The PowerShell Command Snap is a Write Snap that executes a windows powershell command.
Prerequisites
Windows operating system (typically Windows 10 or later) which includes PowerShell pre-installed, and the required permissions(execution policy) to allow script execution.
Support for Ultra Pipelines
Works in Ultra Pipelines.
Snap Views
Type | Format | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|
Input | Document
|
|
| Each document contains data in JSON format. |
Output | Document
|
|
| Each document contains corresponding response in JSON format. |
Error | Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab:
Learn more about Error handling in Pipelines. |
Snap Settings
Expression : JavaScript syntax to access SnapLogic Expressions to set field values dynamically (if enabled). If disabled, you can provide a static value. Learn more.
SnapGPT : Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
Suggestion : Populates a list of values dynamically based on your Account configuration.
Upload : Uploads files. Learn more.
Learn more about the icons in the Snap Settings dialog.
Field Name | Field Type | Description |
---|---|---|
Label*
Default Value: PowerShell Command | String | The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.
|
Launch As
Default Value: | String/Expression | Shall be used to run specific tools and programs with different permissions than the user's current logon provides. %1 is the username and %2 password. For Ex: psexec -u %1 -p %2 |
Source Script* | String/Expression | Script in SLDB to copy on GroundPlex. Use he Fileicon to select the script. For ex: shared/CreateAccount.ps1 |
Dest Script Path* | String/Expression | Absolute path where script shall be placed on GroundPlex. For ex: C:/PowershellScript/CreateAccount.ps1 |
Cmd to Execute* | String/Expression | Command that shall be executed. For ex: powershell.exe C:/PowershellScript/CreateAccount.ps1 |
Is output JSON? | String/Expression | Check box. If selected, the snap will consider the command output in JSON format , otherwise in String |
Snap Execution Default Value: | Dropdown list | Select one of the following three modes in which the Snap executes:
|
Examples
Executing the PowerShell script in the Windows PowerShell and writing the output to a JSON file
We can execute the PowerShell script and save the output to a binary file. This example demonstrates how to use the PowerShell command snap to accomplish this task.
First, we need to write a PowerShell script to a file, upload it to SLDB, and configure it to the setting Source Script in the snap.
Set the values in other settings.
Sample PowerShell script
The script file (script.ps1) will contain the following code.
$output = @(
"Hello from PowerShell Script!"
"Tuesday, February 4, 2025 12:17:43 PM"
)
$output | ConvertTo-Json
Upon validation, we see the following output in the Snap’s preview.
Next, we configure the JSON Formatter & File Writer snaps to format and write it as JSON binary data into a file.
Also, find a few samples of Powershell scripts below.
1) The script file will contain the code Write-Host "Hello, World!" which will print the output below.
The script file will contain the following code which will open the calculator window.
Invoke-Item c:\windows\system32\calc.exe
Download this Pipeline.
Downloads
Download and import the pipeline into the SnapLogic application.
Configure Snap accounts, as applicable.
Provide pipeline parameters, as applicable.
Snap Pack History
Related Content
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2025 SnapLogic, Inc.