# Powershell - Invoke-RestMethod "Delete" Issue for Managed Domain

**URL:** <https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568>\
**Category:** API and Webhooks\
**Created:** [August 10, 2021, 8:42pm UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568 "2021-08-10T20:42:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CRodriguez](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/crodriguez/32/29990_2.png) [@CRodriguez](https://devforum.zoom.us/u/CRodriguez)\
**Post date:** [August 10, 2021, 8:42pm UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568/1 "2021-08-10T20:42:29Z")

</div>

**Description**  
I’m querying users with licenses and specific date since they past logged in.

I need to know where/how I can include the additional string “action=delete” when invoking the DELETE method via Powershell. Since we have a managed domain, the default use of DELETE does not work since it tries to disassociate the account rather than delete.

**Error**  
REST call threw exception: ({“code”:1107,“message”:“You can not disassociate a user with managed domain.”}.Exception)

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
JWT

**Which Endpoint/s?**  
[https://api.zoom.us/v2/users](https://api.zoom.us/v2/users)

**Screenshots (If applicable)**  
Snippet of code below

`#this is just an excerpt of my overall script  
#in this section, if I need to DELETE a user where can I add action=delete?

$global:usersToHaveTheLicenseRemoved | % {  
$currentUserId = $_.id  
$params = @{  
URI = “$zoomUsersEndpoint/$currentUserId”  
Method = ‘DELETE’  
Headers = @{ Authorization = “Bearer $OAuthToken”  
‘Content-Type’ = ‘application/json’ }  
}  
try {  
$global:response = Invoke-RestMethod @params  
}  
catch {  
Write-Host "REST call threw exception: ($_.Exception)"  
$global:exc = $\_  
exit  
}`.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/d/f/dfa955d1d67470c259e2f2b995a07999736c44c6.png)

**Additional context**

I just need to know how/where to include the action=delete string under this global.

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [August 11, 2021, 4:08pm UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568/2 "2021-08-11T16:08:42Z")

</div>

Hey @CRodriguez,

The delete user API requires that the action be included as a query parameter:  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/d/d/dd71b91b9a60e70e15da6d88a86f06d73b0e5f1b.png)

You’ll want to add this to your request URL:  
`?action=delete`

Let me know if this helps to clarify,  
Will

---

<div class="post-metadata">

**Author:** ![CRodriguez](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/crodriguez/32/29990_2.png) [@CRodriguez](https://devforum.zoom.us/u/CRodriguez)\
**Post date:** [August 11, 2021, 6:28pm UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568/4 "2021-08-11T18:28:56Z")

</div>

Hi Will,

Thanks for the response. I’m having trouble understanding how this would be included. Where would the request URL be placed?

Would this be included in the “URI” under the Method Parameters? Example Below  
URI = “$zoomUsersEndpoint/$currentUserId?action=delete”

Thanks.

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [August 12, 2021, 7:58pm UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568/5 "2021-08-12T19:58:51Z")

</div>

Hi @CRodriguez,

That’s correct, this would be part of your `URI` variable within your params object.

Thanks!  
Will

---

<div class="post-metadata">

**Author:** ![CRodriguez](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/crodriguez/32/29990_2.png) [@CRodriguez](https://devforum.zoom.us/u/CRodriguez)\
**Post date:** [August 13, 2021, 4:06pm UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568/6 "2021-08-13T16:06:08Z")

</div>

Thanks Will.

I’m confirming that adding the following under parameters did work for user deletion with the managed domain users.

URI = “$zoomUsersEndpoint/$currentUserId ?action=delete”

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [August 13, 2021, 9:19pm UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568/7 "2021-08-13T21:19:01Z")

</div>

Awesome, glad that did the trick! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [September 13, 2021, 7:19am UTC](https://devforum.zoom.us/t/powershell-invoke-restmethod-delete-issue-for-managed-domain/55568/8 "2021-09-13T07:19:50Z")

</div>

Closed on September 13, 2021, 7:19am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
