# On demand synthetic execution via Powershell script

**URL:** <https://community.dynatrace.com/t/on-demand-synthetic-execution-via-powershell-script/44482>\
**Category:** Synthetic Monitoring\
**Tags:** browser-monitors, synthetic-monitoring\
**Created:** [March 7, 2024, 10:44am UTC](https://community.dynatrace.com/t/on-demand-synthetic-execution-via-powershell-script/44482 "2024-03-07T10:44:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vidhyasagar](https://avatars.discourse-cdn.com/v4/letter/v/a9adbd/32.png) [@Vidhyasagar](https://community.dynatrace.com/u/Vidhyasagar)\
**Post date:** [March 7, 2024, 10:44am UTC](https://community.dynatrace.com/t/on-demand-synthetic-execution-via-powershell-script/44482/1 "2024-03-07T10:44:19Z")

</div>

Hello,

I am working on a requirement to an trigger automated on demand synthetic execution via powershell, invoke method works perfectly fine but I am struggling with request body where I need to change the “monitor id” based on a variable.

Rest API request invoke body

{  
“failOnPerformanceIssue”: false,  
“monitors”: [  
{  
“executionCount”: 1,  
“monitorId”: “SYNTHETIC\_TEST-0200ECC670458A61”,  
“repeatMode”: “SEQUENTIAL”  
}  
],  
“processingMode”: “STANDARD”,  
“takeScreenshotsOnSuccess”: true  
}

Invoke-RestMethod -Uri “https://{environmentid}.live.dynatrace.com/api/v2/synthetic/executions/batch”&nbsp;-Method Post -Body $json -Headers $headers

Any suggestions/solutions will help

---

<div class="post-metadata">

**Author:** ![Miguel\_RinconG](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/miguel_rincong/32/29455_2.png) [@Miguel\_RinconG](https://community.dynatrace.com/u/Miguel_RinconG)\
**Post date:** [March 7, 2024, 1:21pm UTC](https://community.dynatrace.com/t/on-demand-synthetic-execution-via-powershell-script/44482/2 "2024-03-07T13:21:56Z")

</div>

Hi,

I understand do you need use a template of body, and in your script set previously the value of monitorID.

---

<div class="post-metadata">

**Author:** ![Vidhyasagar](https://avatars.discourse-cdn.com/v4/letter/v/a9adbd/32.png) [@Vidhyasagar](https://community.dynatrace.com/u/Vidhyasagar)\
**Post date:** [March 7, 2024, 2:16pm UTC](https://community.dynatrace.com/t/on-demand-synthetic-execution-via-powershell-script/44482/3 "2024-03-07T14:16:08Z")

</div>

Hello Miguel,

In the POST API request body, i want to input the synthetic ID dynamically instead of static value

---

<div class="post-metadata">

**Author:** ![Miguel\_RinconG](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/miguel_rincong/32/29455_2.png) [@Miguel\_RinconG](https://community.dynatrace.com/u/Miguel_RinconG)\
**Post date:** [March 7, 2024, 2:24pm UTC](https://community.dynatrace.com/t/on-demand-synthetic-execution-via-powershell-script/44482/4 "2024-03-07T14:24:16Z")

</div>

Hi,

You can get [synthetics](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/synthetic/synthetic-monitors/get-all-monitors) use a tag filter.
