execute (PowerShell)
Executes user-provided Windows PowerShell cmdlets and/or existing PowerShell scripts on a Windows server/machine. The plugin allows the user to define additional inputs that will be available to the PowerShell scripts during execution. In addition, the user can define any number of outputs from the execution of the PowerShell script that can be utilized in subsequent steps in the workflow.
The plugin provides the user the ability to execute any Azure PowerShell cmdlets installed on the Windows server/machine. Azure PowerShell uses an additional set of cmdlets, which must be installed on the server/machine prior to execution. When executing Azure cmdlets, the inputs and outputs features described above are still available for a user to implement in the code snippet. A link to available Azure PowerShell cmdlets can be found in the execute (PowerShell)#PowerShellAppendix.
All workflow execution properties are also available to the shell script, but any print of secure properties using echo command will result in ***** being printed in FlexDeploy logs. This prevents secure property values like passwords from being visible to any FlexDeploy user.
Inputs
Input Name | Input Code | Required | Description |
---|---|---|---|
Code Snippet |
| Yes | The cmdlets and/or PowerShell scripts that are to be executed in a Windows environment. |
Restrict Environment |
| No | Provide comma-separated target group codes to restrict environment variables in shell to specified target group codes. If no value is provided all properties are available to shell environment. |
No Secure Variables |
| No | Check if you do not want to pass secure/encrypted properties in PowerShell environment. |
Artifacts
This operation delegates consumes/produces artifacts decision to the workflow developer. Check Consumes Artifacts on the workflow step editor if this operation requires artifacts to be delivered prior to execution of the script. Check Produces Artifacts on the workflow step editor if this operation creates artifacts. The artifacts folder is available via the FD_ARTIFACTS_DIR
 variable.
Endpoint Selection
This operation delegates endpoint selection to the workflow developer. The workflow editor will default the selection to "All", which selects all available endpoints associated to the Target. Selecting a specific resource will result in selection of endpoints associated to the Target which have that resource defined.
Endpoint Execution
This operation delegates endpoint execution to the workflow developer. The workflow editor will default to "Any", which will execute on any one of the selected endpoints, which will be randomly picked from selected endpoints or a specific endpoint where previous step may have executed. Changing this value to "All" to will result in execution on all selected endpoints.
Special Considerations
Environment Variables - to use an input in your code snippet, you must create an environment variable by prefixing the plugin variable with $env:
 in order for it to be used by Windows PowerShell. This method must also be applied when using any environment variables, such as JAVA_HOME
or FD_INSTANCE_CODE
. Any number of inputs or properties can be used.
User Inputs
Set-Location -Path $env:filepath Â
Environment Variables
Get-Item $env:FD_ARTIFACTS_DIR
User defined outputs - an output must be defined in the workflow editor to be accessible. Within your script, use the following built-in function to set the output with the appropriate value and have it returned to the workflow process. Any number of outputs can be used.
setOutput {output name} {output value}
Â
Example: setOutput STATUS $env:STATUS_VARIABLE
In the case where your Build or Deployment is hanging on your PowerShell plugin step, the most common issue is that the cmdlet you entered requires user input. If this occurs then you need to force
the cmdlet to complete without the user input and then re-build or re-deploy.
Appendix
A list of available PowerShell cmdlets and their descriptions can be found here.
A list of available Azure PowerShell cmdlets and their descriptions can be found here.
- style