Skip to main content
Version: 2024 R1

Run a PowerShell script

The action may execute any Windows PowerShell command, and after activating certain Powershell add-ins (Exchange, Lync, Azure, Sharepoint), every system operation that can be executed by PowerShell can also be executed via this action.

Examples of operations:
  • creating new catalogues on disk,
  • creating new inbox on Exchange server,
  • Lync account activation,
  • creating user account in Office 365,
  • creating new SharePoint sites.

How to prepare the environment

For this action to work correctly, it is necessary to prepare a server on which PowerShell scripts will be executed.

Necessary server operations:
Enable-PSRemoting [–Force] – configures a computer as the receiver of PowerShell commands, sent using WS-Management technology. Details: https://technet.microsoft.com/en-us/library/hh849694.aspx
Enable-WSManCredSSP [–RoleServer] – activates authentication of: "Credential Security Support Provider" (CredSSP). Details: https://technet.microsoft.com/en-us/library/hh849872.aspx
Set-PSSessionConfiguration [–Name Microsoft.PowerShell1132] [–showSecurityDescriptorUI] – changes session configuration on local computer. Details: https://technet.microsoft.com/en-us/library/hh849726.aspx

Installation

Permissions

The Run PowerShell script action is performed by WEBCON BPS Service in the context of the user for which the service is running. To run scripts in the context of a different user, use the Login and Password parameters available in the action configuration, and then use the $username and $password variables in the script to create the PSCredential object. This object can be safely used in cmdlets that require authentication.

caution

For security reasons it is recommended to always run scripts in the context of a dedicated user with strictly defined permissions.

An approach in which additional permissions required for the proper operation of scripts are granted to the user in the context of which WEBCON BPS Service is running is not recommended.

Action configuration

Run a PowerShell

1. Credentials

The values of the Login and Password parameters will be passed to the PowerShell script as the $username and $password variables. Use these variables to run PowerShell commands in the context of a user with the appropriate permissions.

2. Templates

Allows you to select one of the default templates from which the PowerShell script will be inserted.
Available templates:

  • Exchange: AddMailbox to existing user,
  • LynOnline: Enable Lync for user,
  • 0365: AddMailbox to existing user.

The selected template will be loaded after pressing Insert.

3. PowerShell script

Allows you to enter the script that will be executed by the action. Alternatively, the window presents the entire PowerShell script inserted from Template which can then be edited. The script can contain tags (dynamic values) from Variable Editor.

4. Variables editor

Dynamically generated tree containing all variables that may be used in the current location of Designer Studio. Information on how to use variables in WEBCON BPS, as well as a list of variables can be found here.

tip

In order to use a tag referencing the value of a form field (e.g. {123}) inside a block, it first must be assigned to a variable.

$attValue = '{123}'
$block = {
$attValue
}