> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flexagon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# packageExecute (PowerShell)

> Performs the same function as the Execute operation with the notable difference that it will perform the windows commands on each individual Package D

Performs the same function as the Execute operation with the notable difference that it will perform the windows commands on each individual Package Deploy file. 

See [Project Types](https://flexagon.atlassian.net/wiki/spaces/FD80/pages/10565812235/Project+Types) to create custom Project Type with various File Types and their Attributes. Custom Project Type is very useful with this operation, where you can create custom Package-based Build and Deploy automation. Here are some example scenarios where you custom project type would be useful:

* Source code repository has individual files for Informatica workflow and other objects that needs to be deployed and tracked individually.

* Source control system has individual files defining WebSphere resource configuration and they needs to be deployed and tracked individually.

If you were already using [Generic Project Type](https://flexagon.atlassian.net/wiki/spaces/FD80/pages/10561717223/Generic+Package-based+Project+Type), you can continue to use it as well.

All of the workflow execution properties available with execute are also available here in addition to the below properties:

* PROJECT\_TYPE - Package deploy project type, GENERIC, EBS, MDS etc

* OBJECT\_TYPE\_CODE - Object type for the File.

* File level attributes

  * FILE\_PATH - File path of the package deploy file. (File Name (with path)) on the package deployment screen.

  * FILE\_NAME - File name of the package deploy file

  * FILE\_PATH\_PREFIX - File path, excluding the file name and extension

  * FILE\_EXTENSION - File extension on the package deploy file.

  * FILE\_HASH - The Hash of the file as generated recorded by FlexDeploy

  * FILE\_SCM\_REVISION - The SCM Revision of the package deploy file

  * SOURCE\_FILE - Fully qualified location of the file on the endpoint.

* All file attributes defined on Project Files tab are included as well.

# File level variable example

<table><colgroup><col /><col /></colgroup><tbody><tr><th>**Environment Variable**</th><th>**Value if File Name (with path) is /XXHR/publisher/APXSOBLX\_1.rtf**</th></tr><tr><td>`FILE_PATH`</td><td>/XXHR/publisher/APXSOBLX\_1.rtf</td></tr><tr><td>`FILE_NAME`</td><td>APXSOBLX\_1</td></tr><tr><td>`FILE_PATH_PREFIX`</td><td>/XXHR/publisher</td></tr><tr><td>`FILE_EXTENSION`</td><td>rtf</td></tr><tr><td>`SOURCE_FILE`</td><td>*\<Workflow Execution Temp Directory>*/XXHR/publisher/APXSOBLX\_1.rtf</td></tr></tbody></table>

# Project Properties

<table><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><th>**Property Name**</th><th>**Property Code**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>Project File Includes</td><td>`FD_PARTIAL_FILE_INCLUDES`</td><td>No</td><td>Controls files included in Project Files. Enter expressions separated by ##. Leave empty to select all files. Begin or end the expression with \* for simple wildcards. Otherwise, regex\
is used. (e.g. /java/*##*.java##*person*##/java/.*\[tT]est.*.java)</td></tr><tr><td>Project File Excludes</td><td>`FD_PARTIAL_FILE_EXCLUDES`</td><td>No</td><td>Controls files excluded from Project Files. Enter expressions separated by ##. Leave empty to select all files. Begin or end the expression with \* for simple wildcards. Otherwise,\
regex is used. (e.g. /java/*##*.java##*person*##/java/.*\[tT]est.*.java)</td></tr><tr><td>Stop On Deployment Error</td><td>`FDSHELL_STOP_ON_DEPLOYMENT_ERROR`</td><td>No</td><td>Stop deploying package files if any error occurs. If unchecked all files will be deployed even if one or more files fails. This is for packageExecute operations only.</td></tr></tbody></table>

# Inputs

<table><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><th>**Input Name**</th><th>**Input Code**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>Code Snippet</td><td>`FDPWRSHELL_INP_CODE_SNIPPET`</td><td>Yes</td><td>The cmdlets and/or PowerShell scripts that are to be executed in a Windows environment.</td></tr><tr><td>Use PowerShell 6+</td><td>`FDPWRSHELL_INP_POWERSHELL6_OR_ABOVE`</td><td>No</td><td>Check If you want to execute the script on PowerShell 6+.If it is unchecked then it will execute on PowerShell 1-5.</td></tr><tr><td>Restrict Environment</td><td>`FDPWRSHELL_INP_RESTRICT_ENVIRONMENT`</td><td>No</td><td>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.</td></tr><tr><td>Continue On Error</td><td>`FDPWRSHELL_INP_CONTINUE_ON_ERROR`</td><td>No</td><td>Flag that indicates whether the PowerShell script should continue on an error or stop on processing.Check if you want to continue execution of PowerShell script when error occurs.</td></tr><tr><td>No Secure Variables</td><td>`FDPWRSHELL_INP_NO_SECURE_VARIABLES`</td><td>No</td><td>Check if you do not want to pass secure/encrypted properties in PowerShell environment.</td></tr><tr><td>Perform Property Replacement</td><td>`FDSHELL_INP_PERFORM_PROPERTY_REPLACEMENT`</td><td>No</td><td>Check to perform property replacement on source file before execution of script.</td></tr></tbody></table>

# Outputs

<table><colgroup><col /><col /><col /></colgroup><tbody><tr><th>**Output Name**</th><th>**Required**</th><th>**Description**</th></tr><tr><td>User Defined</td><td>No</td><td>See ***Special Considerations*** below.</td></tr></tbody></table>

# 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 RESULT $env:RESULT_VARIABLE
```

**Outputs are aggregated into a csv list for package deployments.**

The above RESULT example would contain an entry for each file in the object list.  \[YES, NO]

##### **Indicate file was not processed and should not consider status**

```
# just call ignoreStatus for File that this shell did not process
ignoreStatus
```

**Overriding the file status**

There may be cases when you want to manually set the status for any particular file when scripting.  The below functions can be utilized to set the status of the file as you see fit:

```
setObjectResultStatusSuccess
setObjectResultStatusFailed
setObjectResultStatusSkipped
setObjectResultStatusNotAttempted
setObjectResultStatusIgnore
```

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.

```
Stop-AzureRmVM -Name "VirtualMachine3" -ResourceGroupName "ResourceGroup5" -Force 
```

# Appendix

A list of available PowerShell cmdlets and their descriptions can be found [here](http://ss64.com/ps/).

A list of available Azure PowerShell cmdlets and their descriptions can be found [here](https://msdn.microsoft.com/en-us/library/azure/mt619274.aspx).
