Skip to main content
Skip table of contents

Execute Powershell

Tag: ExecutePowershell

Ytria Automation can execute any Powershell script. It will run with the credentials associated with the current session.


Tag Attributes

AttributesAttribute ValuesValue Description
ScriptN/APowerShell script to execute
OnPremisesTRUE / FALSE (Defaults to FALSE) - If TRUE, execute in On-Premises context. If not, use Exchange context (Mailbox, MFA, etc.)N/A - Optional
UseIPPSTRUE / FALSE (Defaults to FALSE)N/A - Optional

Detailed Description

Output MUST be configured using SetParam sub-actions:

<SetParam Name="STREAM_NAME" Value="OUTPUT_VAR_NAME" FilePath="OUTPUT_FILE_NAME"/>


STREAM_NAME can be:

  • Output (== Write-Output)
  • Debug (== Write-Debug)
  • Error (== Write-Error)
  • Information (== Write-Information)
  • Verbose (== Write-Verbose )\
  • Warning (== Write-Warning)

OUTPUT_VAR_NAME is the output var name. OUTPUT_FILE_NAME is the output file path. At least one of them must be non-empty. If both are, OUTPUT_VAR_NAME wins.

Additionally, at least one output (one SetParam) must be configured. One stream can't be used more than once for one ExecutePowershell. Several streams can be used for one ExecutePowershell.

Important Note
Any string result will end up in Output stream. But if your script returns an object (or collection of objects), Output stream will stay empty.

For instance:
This will generate an Output: script="Get-Mailbox 94bcbf02-692c-4f62-b620-f15408e1528f | ConvertTo-Csv -NoTypeInformation"
This will not: script="Get-Mailbox 94bcbf02-692c-4f62-b620-f15408e1528f"

Example Script

XML
<ytriaAutomation Application="sapio365">
	<ExecutePowershellScript script="Write-Output 'This is my success';Write-Debug 'This is my debug';Write-Error 'This is my error';Write-Information 'This is my information';Write-		
	Verbose 'This is my verbose';Write-Warning 'This is my warning';">
		<SetParam Name="Output" FilePath="myOutput.txt"/> <!-- Main output to file -->
		<SetParam Name="Debug" Value="myDebug"/>
		<SetParam Name="Error" Value="myError"/>
		<SetParam Name="Information" Value="myInformation"/>
		<SetParam Name="Verbose" Value="myVerbose"/>
		<SetParam Name="Warning" Value="myWarning"/>
	</ExecutePowershellScript>
	<echo value="{%myDebug%}"/>
	<echo value="{%myError%}"/>
	<echo value="{%myInformation%}"/>
	<echo value="{%myVerbose%}"/>
	<echo value="{%myWarning%}"/>
</ytriaAutomation>
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.