{"componentChunkName":"component---src-templates-simple-markdown-js","path":"/cpm/developer/rest-api/how-to/powershell/rest-using-powershell/","matchPath":"","result":{"data":{"markdownRemark":{"html":"<h1 style=\"position:relative;\"><a href=\"#celonis-process-management-rest-access-using-powershell\" aria-label=\"celonis process management rest access using powershell permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"celonis-process-management-rest-access-using-powershell\"></div>Celonis Process Management REST access using Powershell</h1>\n<h2 style=\"position:relative;\"><a href=\"#pre-requisites\" aria-label=\"pre requisites permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"pre-requisites\"></div>Pre-requisites</h2>\n<ul>\n<li>\nAuthentication token that is active and valid\n</li>\n<li>\nRequired parameters: \n<ul>\n<li>\nServer name\n</li>\n<li>\nStorage collection name\n</li>\n<li>\nStorage name\n</li>\n<li>\nREST authentication token\n</li>\n</ul>\n</li>\n</ul>\n<h2 style=\"position:relative;\"><a href=\"#executing-a-rest-command-using-powershell\" aria-label=\"executing a rest command using powershell permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"executing-a-rest-command-using-powershell\"></div>Executing a REST command using Powershell</h2>\n<p>The Invoke-RestMethod cmdlet sends HTTP and HTTPS requests to Representational State Transfer (REST) web services that returns richly structured data.</p>\n<p>PowerShell formats the response based to the data type. </p>\n<p>For more information please have a look at the documentation on Microsoft: <a href=\"https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-6\">Microsoft documentation</a></p>\n<h2 style=\"position:relative;\"><a href=\"#example-script-to-get-released-processes-or-documents\" aria-label=\"example script to get released processes or documents permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"example-script-to-get-released-processes-or-documents\"></div>Example script to get released processes or documents</h2>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"31186849894311973000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`\tfunction Fetch_Data {\n\t\t[CmdletBinding()]\n\t\t# Parameters for collecting data\n\t\tparam(\n\t\t\t# Server address parameter\n\t\t\t[Parameter(Mandatory=\\\\$true, HelpMessage=&quot;Please enter the server address!&quot;, Position=1)]\n\t\t\t[ValidateNotNullOrEmpty()]\n\t\t\t[string]\\\\$address,\n\n\t\t\t# Collection name parameter\n\t\t\t[Parameter(Mandatory=\\\\$true, HelpMessage=&quot;Please enter the collection name!&quot;, Position=2)]\n\t\t\t[ValidateNotNullOrEmpty()]\n\t\t\t[string]\\\\$collection,\n\n\t\t\t# Storage name parameter\n\t\t\t[Parameter(Mandatory=\\\\$true, HelpMessage=&quot;Please enter the storage name!&quot;, Position=3)]\n\t\t\t[ValidateNotNullOrEmpty()]\n\t\t\t[string]\\\\$storage,\n\n\t\t\t# REST API Token parameter\n\t\t\t[Parameter(Mandatory=\\\\$true, HelpMessage=&quot;Please enter the REST API token!&quot;, Position=4)]\n\t\t\t[ValidateNotNullOrEmpty()]\n\t\t\t[string]\\\\$token,\n\t\t\n\t\t\t# Export data to file parameter. False is default. Parameter is not mandatory\n\t\t\t[Parameter(Mandatory=\\\\$false, HelpMessage=&quot;Export result in json file?&quot;, Position=5)]\n\t\t\t[bool]\\\\$fileExport = \\\\$false\n\t\t)\n\n\t\tProcess\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\t\\\\$params = @{\n\t\t\t\t    Uri = &quot;https://\\\\$(\\\\$address)/\\\\$(\\\\$collection)/\\\\$(\\\\$storage)/_api/rest/facets/processes/views/lastReleasedProcesses/elements&quot;\n\t\t\t\t    Headers = @{ 'symbio-auth-token' =  \\\\$token; 'api-version' = '2.0' }\n\t\t\t\t    Method = 'GET'\n\t\t\t\t    ContentType = 'application/json'\n\t\t\t\t}\n\n\t\t\t\t# Response of the API request. Data will be taken with depth of 10 levels\n\t\t\t\t\\\\$result = Invoke-RestMethod @params | ConvertTo-Json -Depth 10\n\n\t\t\t\t# Converting from JSON to table data (Easier for customization of fields and ordering)\n\t\t\t\t\\\\$tableResult = \\\\$result | ConvertFrom-Json\n\n\t\t\t\t\\\\$valuesResult = ''\n\n\t\t\t\t# All data is putting to one table object\n\t\t\t\t\\\\$hash = @{}\n\t\t\t\tforeach(\\\\$row in \\\\$tableResult.PSObject.Properties){\n\t\t\t\tif(\\\\$row.Value -is [int]) { continue }\n\t\t\t\t\t\\\\$hash[\\\\$row.Name] = \\\\$row.Value\n\t\t\t\t\t\\\\$valuesResult = \\\\$hash[\\\\$row.Name]\n\t\t\t\t}\n\n\t\t\t\t\\\\$arrayOfElements = New-Object System.Collections.ArrayList\n\n\t\t\t\t# Mapping all data to fields which will be shown to the final data\n\t\t\t\tforeach(\\\\$element in \\\\$valuesResult)\n\t\t\t\t{\n\t\t\t\t\t\\\\$parameters = [ordered]@{\n\t\t\t\t\t\tName = \\\\$element.attributes.Name\n\t\t\t\t\t\tState = \\\\$element.attributes.state1\n\t\t\t\t\t\tType = \\\\$element.type\n\t\t\t\t\t\tLinkAddress = \\\\$element.attributes.links.'127'.fullAddress\n\t\t\t\t\t\tLinkTitle = \\\\$element.attributes.links.'127'.title\n\t\t\t\t\t} \n\t\t\t\t\t[void]\\\\$arrayOfElements.Add(\\\\$parameters)\n\t\t\t\t}\n\n\t\t\t\t# Checking if the data is not empty\n\t\t\t\tif(\\\\$arrayOfElements.Count -lt 1)\n\t\t\t\t{\n\t\t\t\t\tWrite-Host &quot;Response returned 0 elements. Please check input parameters, and try again...&quot;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n                    # If the data isn't empty, it's checking if parameter export to file is True\n                    \\\\$file_export = \\\\$fileExport\n                    \\\\$today = Get-Date -Format yyyy-MM-ddTHH-mm-ss-ff\n                    if(\\\\$file_export -eq \\\\$true) \n                    {\n                        \\\\$arrayOfElements | ConvertTo-Json | Out-File &quot;.\\\\processes\\\\$(\\\\$today).json&quot;\n                    }\n                    else { \\\\$arrayOfElements | ConvertTo-Json }\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch [System.Management.Automation.CommandNotFoundException]\n\t\t\t{\n\t\t\t\tWrite-Host &quot;Command not found. Please execute again...&quot;\n\t\t\t\tWrite-Host \\\\$_.ScriptStackTrace\n\t\t\t}\n\t\t\tcatch [System.Net.WebException],[System.SystemException]\n\t\t\t{\n\t\t\t\tWrite-Host &quot;Web error. Please check input parameters and try again.&quot;\n\t\t\t\tWrite-Host \\\\$_.ScriptStackTrace\n\t\t\t}\n\t\t}\n\t}`, `31186849894311973000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-31186849894311973000\">Copied</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\">\t<span class=\"token keyword\">function</span> Fetch_Data <span class=\"token punctuation\">{</span>\n\t\t<span class=\"token namespace\">[CmdletBinding()]</span>\n\t\t<span class=\"token comment\"># Parameters for collecting data</span>\n\t\t<span class=\"token keyword\">param</span><span class=\"token punctuation\">(</span>\n\t\t\t<span class=\"token comment\"># Server address parameter</span>\n\t\t\t<span class=\"token punctuation\">[</span>Parameter<span class=\"token punctuation\">(</span>Mandatory=<span class=\"token boolean\">$true</span><span class=\"token punctuation\">,</span> HelpMessage=<span class=\"token string\">\"Please enter the server address!\"</span><span class=\"token punctuation\">,</span> Position=1<span class=\"token punctuation\">)</span><span class=\"token punctuation\">]</span>\n\t\t\t<span class=\"token namespace\">[ValidateNotNullOrEmpty()]</span>\n\t\t\t<span class=\"token namespace\">[string]</span><span class=\"token variable\">$address</span><span class=\"token punctuation\">,</span>\n\n\t\t\t<span class=\"token comment\"># Collection name parameter</span>\n\t\t\t<span class=\"token punctuation\">[</span>Parameter<span class=\"token punctuation\">(</span>Mandatory=<span class=\"token boolean\">$true</span><span class=\"token punctuation\">,</span> HelpMessage=<span class=\"token string\">\"Please enter the collection name!\"</span><span class=\"token punctuation\">,</span> Position=2<span class=\"token punctuation\">)</span><span class=\"token punctuation\">]</span>\n\t\t\t<span class=\"token namespace\">[ValidateNotNullOrEmpty()]</span>\n\t\t\t<span class=\"token namespace\">[string]</span><span class=\"token variable\">$collection</span><span class=\"token punctuation\">,</span>\n\n\t\t\t<span class=\"token comment\"># Storage name parameter</span>\n\t\t\t<span class=\"token punctuation\">[</span>Parameter<span class=\"token punctuation\">(</span>Mandatory=<span class=\"token boolean\">$true</span><span class=\"token punctuation\">,</span> HelpMessage=<span class=\"token string\">\"Please enter the storage name!\"</span><span class=\"token punctuation\">,</span> Position=3<span class=\"token punctuation\">)</span><span class=\"token punctuation\">]</span>\n\t\t\t<span class=\"token namespace\">[ValidateNotNullOrEmpty()]</span>\n\t\t\t<span class=\"token namespace\">[string]</span><span class=\"token variable\">$storage</span><span class=\"token punctuation\">,</span>\n\n\t\t\t<span class=\"token comment\"># REST API Token parameter</span>\n\t\t\t<span class=\"token punctuation\">[</span>Parameter<span class=\"token punctuation\">(</span>Mandatory=<span class=\"token boolean\">$true</span><span class=\"token punctuation\">,</span> HelpMessage=<span class=\"token string\">\"Please enter the REST API token!\"</span><span class=\"token punctuation\">,</span> Position=4<span class=\"token punctuation\">)</span><span class=\"token punctuation\">]</span>\n\t\t\t<span class=\"token namespace\">[ValidateNotNullOrEmpty()]</span>\n\t\t\t<span class=\"token namespace\">[string]</span><span class=\"token variable\">$token</span><span class=\"token punctuation\">,</span>\n\t\t\n\t\t\t<span class=\"token comment\"># Export data to file parameter. False is default. Parameter is not mandatory</span>\n\t\t\t<span class=\"token punctuation\">[</span>Parameter<span class=\"token punctuation\">(</span>Mandatory=<span class=\"token boolean\">$false</span><span class=\"token punctuation\">,</span> HelpMessage=<span class=\"token string\">\"Export result in json file?\"</span><span class=\"token punctuation\">,</span> Position=5<span class=\"token punctuation\">)</span><span class=\"token punctuation\">]</span>\n\t\t\t<span class=\"token namespace\">[bool]</span><span class=\"token variable\">$fileExport</span> = <span class=\"token boolean\">$false</span>\n\t\t<span class=\"token punctuation\">)</span>\n\n\t\t<span class=\"token keyword\">Process</span>\n\t\t<span class=\"token punctuation\">{</span>\n\t\t\t<span class=\"token keyword\">try</span>\n\t\t\t<span class=\"token punctuation\">{</span>\n\t\t\t\t<span class=\"token variable\">$params</span> = @<span class=\"token punctuation\">{</span>\n\t\t\t\t    Uri = <span class=\"token string\">\"https://<span class=\"token function\">$<span class=\"token punctuation\">(</span><span class=\"token variable\">$address</span><span class=\"token punctuation\">)</span></span>/<span class=\"token function\">$<span class=\"token punctuation\">(</span><span class=\"token variable\">$collection</span><span class=\"token punctuation\">)</span></span>/<span class=\"token function\">$<span class=\"token punctuation\">(</span><span class=\"token variable\">$storage</span><span class=\"token punctuation\">)</span></span>/_api/rest/facets/processes/views/lastReleasedProcesses/elements\"</span>\n\t\t\t\t    Headers = @<span class=\"token punctuation\">{</span> <span class=\"token string\">'symbio-auth-token'</span> =  <span class=\"token variable\">$token</span><span class=\"token punctuation\">;</span> <span class=\"token string\">'api-version'</span> = <span class=\"token string\">'2.0'</span> <span class=\"token punctuation\">}</span>\n\t\t\t\t    Method = <span class=\"token string\">'GET'</span>\n\t\t\t\t    ContentType = <span class=\"token string\">'application/json'</span>\n\t\t\t\t<span class=\"token punctuation\">}</span>\n\n\t\t\t\t<span class=\"token comment\"># Response of the API request. Data will be taken with depth of 10 levels</span>\n\t\t\t\t<span class=\"token variable\">$result</span> = <span class=\"token function\">Invoke-RestMethod</span> @params <span class=\"token punctuation\">|</span> <span class=\"token function\">ConvertTo-Json</span> <span class=\"token operator\">-</span>Depth 10\n\n\t\t\t\t<span class=\"token comment\"># Converting from JSON to table data (Easier for customization of fields and ordering)</span>\n\t\t\t\t<span class=\"token variable\">$tableResult</span> = <span class=\"token variable\">$result</span> <span class=\"token punctuation\">|</span> <span class=\"token function\">ConvertFrom-Json</span>\n\n\t\t\t\t<span class=\"token variable\">$valuesResult</span> = <span class=\"token string\">''</span>\n\n\t\t\t\t<span class=\"token comment\"># All data is putting to one table object</span>\n\t\t\t\t<span class=\"token variable\">$hash</span> = @<span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span>\n\t\t\t\t<span class=\"token keyword\">foreach</span><span class=\"token punctuation\">(</span><span class=\"token variable\">$row</span> in <span class=\"token variable\">$tableResult</span><span class=\"token punctuation\">.</span>PSObject<span class=\"token punctuation\">.</span>Properties<span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span>\n\t\t\t\t<span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span><span class=\"token variable\">$row</span><span class=\"token punctuation\">.</span>Value <span class=\"token operator\">-is</span> <span class=\"token namespace\">[int]</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span> <span class=\"token keyword\">continue</span> <span class=\"token punctuation\">}</span>\n\t\t\t\t\t<span class=\"token variable\">$hash</span><span class=\"token punctuation\">[</span><span class=\"token variable\">$row</span><span class=\"token punctuation\">.</span>Name<span class=\"token punctuation\">]</span> = <span class=\"token variable\">$row</span><span class=\"token punctuation\">.</span>Value\n\t\t\t\t\t<span class=\"token variable\">$valuesResult</span> = <span class=\"token variable\">$hash</span><span class=\"token punctuation\">[</span><span class=\"token variable\">$row</span><span class=\"token punctuation\">.</span>Name<span class=\"token punctuation\">]</span>\n\t\t\t\t<span class=\"token punctuation\">}</span>\n\n\t\t\t\t<span class=\"token variable\">$arrayOfElements</span> = <span class=\"token function\">New-Object</span> System<span class=\"token punctuation\">.</span>Collections<span class=\"token punctuation\">.</span>ArrayList\n\n\t\t\t\t<span class=\"token comment\"># Mapping all data to fields which will be shown to the final data</span>\n\t\t\t\t<span class=\"token keyword\">foreach</span><span class=\"token punctuation\">(</span><span class=\"token variable\">$element</span> in <span class=\"token variable\">$valuesResult</span><span class=\"token punctuation\">)</span>\n\t\t\t\t<span class=\"token punctuation\">{</span>\n\t\t\t\t\t<span class=\"token variable\">$parameters</span> = <span class=\"token namespace\">[ordered]</span>@<span class=\"token punctuation\">{</span>\n\t\t\t\t\t\tName = <span class=\"token variable\">$element</span><span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>Name\n\t\t\t\t\t\tState = <span class=\"token variable\">$element</span><span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>state1\n\t\t\t\t\t\t<span class=\"token function\">Type</span> = <span class=\"token variable\">$element</span><span class=\"token punctuation\">.</span><span class=\"token function\">type</span>\n\t\t\t\t\t\tLinkAddress = <span class=\"token variable\">$element</span><span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>links<span class=\"token punctuation\">.</span><span class=\"token string\">'127'</span><span class=\"token punctuation\">.</span>fullAddress\n\t\t\t\t\t\tLinkTitle = <span class=\"token variable\">$element</span><span class=\"token punctuation\">.</span>attributes<span class=\"token punctuation\">.</span>links<span class=\"token punctuation\">.</span><span class=\"token string\">'127'</span><span class=\"token punctuation\">.</span>title\n\t\t\t\t\t<span class=\"token punctuation\">}</span> \n\t\t\t\t\t<span class=\"token namespace\">[void]</span><span class=\"token variable\">$arrayOfElements</span><span class=\"token punctuation\">.</span>Add<span class=\"token punctuation\">(</span><span class=\"token variable\">$parameters</span><span class=\"token punctuation\">)</span>\n\t\t\t\t<span class=\"token punctuation\">}</span>\n\n\t\t\t\t<span class=\"token comment\"># Checking if the data is not empty</span>\n\t\t\t\t<span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span><span class=\"token variable\">$arrayOfElements</span><span class=\"token punctuation\">.</span>Count <span class=\"token operator\">-lt</span> 1<span class=\"token punctuation\">)</span>\n\t\t\t\t<span class=\"token punctuation\">{</span>\n\t\t\t\t\t<span class=\"token function\">Write-Host</span> <span class=\"token string\">\"Response returned 0 elements. Please check input parameters, and try again...\"</span>\n\t\t\t\t<span class=\"token punctuation\">}</span>\n\t\t\t\t<span class=\"token keyword\">else</span>\n\t\t\t\t<span class=\"token punctuation\">{</span>\n                    <span class=\"token comment\"># If the data isn't empty, it's checking if parameter export to file is True</span>\n                    <span class=\"token variable\">$file_export</span> = <span class=\"token variable\">$fileExport</span>\n                    <span class=\"token variable\">$today</span> = <span class=\"token function\">Get-Date</span> <span class=\"token operator\">-</span>Format yyyy-MM-ddTHH-mm-ss-ff\n                    <span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span><span class=\"token variable\">$file_export</span> <span class=\"token operator\">-eq</span> <span class=\"token boolean\">$true</span><span class=\"token punctuation\">)</span> \n                    <span class=\"token punctuation\">{</span>\n                        <span class=\"token variable\">$arrayOfElements</span> <span class=\"token punctuation\">|</span> <span class=\"token function\">ConvertTo-Json</span> <span class=\"token punctuation\">|</span> <span class=\"token function\">Out-File</span> <span class=\"token string\">\".\\processes<span class=\"token function\">$<span class=\"token punctuation\">(</span><span class=\"token variable\">$today</span><span class=\"token punctuation\">)</span></span>.json\"</span>\n                    <span class=\"token punctuation\">}</span>\n                    <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span> <span class=\"token variable\">$arrayOfElements</span> <span class=\"token punctuation\">|</span> <span class=\"token function\">ConvertTo-Json</span> <span class=\"token punctuation\">}</span>\n\t\t\t\t<span class=\"token punctuation\">}</span>\n\t\t\t<span class=\"token punctuation\">}</span>\n\t\t\t<span class=\"token keyword\">catch</span> <span class=\"token namespace\">[System.Management.Automation.CommandNotFoundException]</span>\n\t\t\t<span class=\"token punctuation\">{</span>\n\t\t\t\t<span class=\"token function\">Write-Host</span> <span class=\"token string\">\"Command not found. Please execute again...\"</span>\n\t\t\t\t<span class=\"token function\">Write-Host</span> <span class=\"token variable\">$_</span><span class=\"token punctuation\">.</span>ScriptStackTrace\n\t\t\t<span class=\"token punctuation\">}</span>\n\t\t\t<span class=\"token keyword\">catch</span> <span class=\"token namespace\">[System.Net.WebException]</span><span class=\"token punctuation\">,</span><span class=\"token namespace\">[System.SystemException]</span>\n\t\t\t<span class=\"token punctuation\">{</span>\n\t\t\t\t<span class=\"token function\">Write-Host</span> <span class=\"token string\">\"Web error. Please check input parameters and try again.\"</span>\n\t\t\t\t<span class=\"token function\">Write-Host</span> <span class=\"token variable\">$_</span><span class=\"token punctuation\">.</span>ScriptStackTrace\n\t\t\t<span class=\"token punctuation\">}</span>\n\t\t<span class=\"token punctuation\">}</span>\n\t<span class=\"token punctuation\">}</span></code></pre></div>\n      </div>\n<h2 style=\"position:relative;\"><a href=\"#example-output\" aria-label=\"example output permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"example-output\"></div>Example output</h2>\n<p>The script can output the json directly, or create a file with the same content, depending on the $fileExport parameter.</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"12563385233501467000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`\t[\n\t\t{\n\t\t\t&quot;Name&quot;:  {\n\t\t\t\t\t\t &quot;1033&quot;:  &quot;Sub Process 1&quot;,\n\t\t\t\t\t\t &quot;1031&quot;:  &quot;Teilprozess 1&quot;\n\t\t\t\t\t },\n\t\t\t&quot;State&quot;:  null,\n\t\t\t&quot;Type&quot;:  &quot;subProcess&quot;,\n\t\t\t&quot;LinkAddress&quot;:  null,\n\t\t\t&quot;LinkTitle&quot;:  null\n\t\t},\n\t\t{\n\t\t\t&quot;Name&quot;:  {\n\t\t\t\t\t\t &quot;1033&quot;:  &quot;Sub Process 2&quot;,\n\t\t\t\t\t\t &quot;1031&quot;:  &quot;Teilprozess 2&quot;\n\t\t\t\t\t },\n\t\t\t&quot;State&quot;:  &quot;InProgress&quot;,\n\t\t\t&quot;Type&quot;:  &quot;subProcess&quot;,\n\t\t\t&quot;LinkAddress&quot;:  null,\n\t\t\t&quot;LinkTitle&quot;:  null\n\t\t},\n\t\t{\n\t\t\t&quot;Name&quot;:  {\n\t\t\t\t\t\t &quot;1033&quot;:  &quot;Sub Process 3&quot;,\n\t\t\t\t\t\t &quot;1031&quot;:  &quot;Teilprozess 3&quot;\n\t\t\t\t\t },\n\t\t\t&quot;State&quot;:  null,\n\t\t\t&quot;Type&quot;:  &quot;subProcess&quot;,\n\t\t\t&quot;LinkAddress&quot;:  null,\n\t\t\t&quot;LinkTitle&quot;:  null\n\t\t},\n\t]`, `12563385233501467000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-12563385233501467000\">Copied</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\">\t<span class=\"token punctuation\">[</span>\n\t\t<span class=\"token punctuation\">{</span>\n\t\t\t<span class=\"token property\">\"Name\"</span><span class=\"token operator\">:</span>  <span class=\"token punctuation\">{</span>\n\t\t\t\t\t\t <span class=\"token property\">\"1033\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"Sub Process 1\"</span><span class=\"token punctuation\">,</span>\n\t\t\t\t\t\t <span class=\"token property\">\"1031\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"Teilprozess 1\"</span>\n\t\t\t\t\t <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"State\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"Type\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"subProcess\"</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"LinkAddress\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"LinkTitle\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span>\n\t\t<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n\t\t<span class=\"token punctuation\">{</span>\n\t\t\t<span class=\"token property\">\"Name\"</span><span class=\"token operator\">:</span>  <span class=\"token punctuation\">{</span>\n\t\t\t\t\t\t <span class=\"token property\">\"1033\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"Sub Process 2\"</span><span class=\"token punctuation\">,</span>\n\t\t\t\t\t\t <span class=\"token property\">\"1031\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"Teilprozess 2\"</span>\n\t\t\t\t\t <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"State\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"InProgress\"</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"Type\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"subProcess\"</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"LinkAddress\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"LinkTitle\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span>\n\t\t<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n\t\t<span class=\"token punctuation\">{</span>\n\t\t\t<span class=\"token property\">\"Name\"</span><span class=\"token operator\">:</span>  <span class=\"token punctuation\">{</span>\n\t\t\t\t\t\t <span class=\"token property\">\"1033\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"Sub Process 3\"</span><span class=\"token punctuation\">,</span>\n\t\t\t\t\t\t <span class=\"token property\">\"1031\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"Teilprozess 3\"</span>\n\t\t\t\t\t <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"State\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"Type\"</span><span class=\"token operator\">:</span>  <span class=\"token string\">\"subProcess\"</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"LinkAddress\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span><span class=\"token punctuation\">,</span>\n\t\t\t<span class=\"token property\">\"LinkTitle\"</span><span class=\"token operator\">:</span>  <span class=\"token null keyword\">null</span>\n\t\t<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n\t<span class=\"token punctuation\">]</span></code></pre></div>\n      </div>\n<h2 style=\"position:relative;\"><a href=\"#how-to-call-the-powershell-script\" aria-label=\"how to call the powershell script permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"how-to-call-the-powershell-script\"></div>How to call the Powershell script</h2>\n<p>You can save the script in a ****.ps file.\nThe parameters are:</p>\n<ol>\n<li>\nServer name\n</li>\n<li>\nStorage collection name\n</li>\n<li>\nStorage name\n</li>\n<li>\nAuthentication token\n</li>\n<li>\nFile export (true/false) (Optional parameter)\n</li>\n</ol>\n<h3 style=\"position:relative;\"><a href=\"#running-it-with-user-input\" aria-label=\"running it with user input permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"running-it-with-user-input\"></div>Running it with user input</h3>\n<p>When running the the script file without parameters, the script will prompt you to enter the required values. Using !? at that point will give you a hint on the required value.</p>\n<h3 style=\"position:relative;\"><a href=\"#running-inline\" aria-label=\"running inline permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"running-inline\"></div>Running inline</h3>\n<p>You can also run the script and provide the required parameters at runtime.\nExample:</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"55357967423382590000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`\trun.ps -address <servername> -collection <collection-name> -storage <storage-name> -token <auth-token> -dataType 1 -fileExport false`, `55357967423382590000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-55357967423382590000\">Copied</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">\trun.ps -address &lt;servername> -collection &lt;collection-name> -storage &lt;storage-name> -token &lt;auth-token> -dataType 1 -fileExport false</code></pre></div>\n      </div>","headings":[{"value":"Celonis Process Management REST access using Powershell","depth":1},{"value":"Pre-requisites","depth":2},{"value":"Executing a REST command using Powershell","depth":2},{"value":"Example script to get released processes or documents","depth":2},{"value":"Example output","depth":2},{"value":"How to call the Powershell script","depth":2},{"value":"Running it with user input","depth":3},{"value":"Running inline","depth":3}]},"contentItem":{"data":{"lastModified":"2025-09-10T14:16:09.000Z","enableToc":null,"disableLastModified":null,"tocMaxDepth":null,"requestLogin":false}},"siteConfig":{"enableToc":false,"disableLastModified":false,"tocMaxDepth":4}},"pageContext":{"matchPath":"","id":"2adaeb4a-7e46-562b-8594-6a1946a063bd__redocly content/cpm/developer/rest-api/how-to/powershell/rest-using-powershell/","seo":{"title":"Celonis Process Management REST access using Powershell","description":null,"image":"","keywords":null,"jsonLd":null,"lang":null,"siteUrl":null},"pageId":"cpm/developer/rest-api/how-to/powershell/rest-using-powershell.md","pageBaseUrl":"/cpm/developer/rest-api/how-to/powershell/rest-using-powershell","type":"markdown","toc":{"enable":true,"maxDepth":4,"headings":[{"depth":1,"value":"Celonis Process Management REST access using Powershell","id":"celonis-process-management-rest-access-using-powershell"},{"depth":2,"value":"Pre-requisites","id":"pre-requisites"},{"depth":2,"value":"Executing a REST command using Powershell","id":"executing-a-rest-command-using-powershell"},{"depth":2,"value":"Example script to get released processes or documents","id":"example-script-to-get-released-processes-or-documents"},{"depth":2,"value":"Example output","id":"example-output"},{"depth":2,"value":"How to call the Powershell script","id":"how-to-call-the-powershell-script"},{"depth":3,"value":"Running it with user input","id":"running-it-with-user-input"},{"depth":3,"value":"Running inline","id":"running-inline"}]},"data":{"title":""},"catalogInfo":null,"link":"/cpm/developer/rest-api/how-to/powershell/rest-using-powershell/","sidebarName":"celonis","isLanding":false,"showPrevButton":null,"showNextButton":null,"apiVersions":null,"apiVersionId":null,"isDefaultApiVersion":null}},"staticQueryHashes":["1123603147","1302185487","1344209882","1398840060","1520077861","1975142765","2667623876","2950305614","3240152602","3743992808","561138138"]}