# Bulk Account Disabling

**URL:** <https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948>\
**Category:** SHF Discussion and Questions\
**Tags:** sailpoint-identity-security\
**Created:** [February 9, 2024, 5:36pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948 "2024-02-09T17:36:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sai\_Sumanth\_Golla](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@Sai\_Sumanth\_Golla](https://developer.sailpoint.com/discuss/u/Sai_Sumanth_Golla)\
**Post date:** [February 9, 2024, 5:36pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948/1 "2024-02-09T17:36:20Z")

</div>

Hi Experts,

We need to disable 1k+ accounts on a source (with 5k+ accounts), please kick start me with some ideas, thanks in advance.

---

<div class="post-metadata">

**Author:** ![iamology](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/iamology/32/6964_2.png) [@iamology](https://developer.sailpoint.com/discuss/u/iamology)\
**Post date:** [February 9, 2024, 6:35pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948/2 "2024-02-09T18:35:19Z")

</div>

Have you considered running a script to call Account Update API?  
`PATCH ..../beta/accounts/:accountId`

body

```auto
[
    { 
        "op": "replace", 
        "path": "/disabled", 
        "value": true
    }
]

```

---

<div class="post-metadata">

**Author:** ![BenNelson](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/bennelson/32/6002_2.png) [@BenNelson](https://developer.sailpoint.com/discuss/u/BenNelson)\
**Post date:** [February 9, 2024, 7:58pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948/3 "2024-02-09T19:58:28Z")

</div>

You could use a workflow to do it if you can craft a search query that can get all of the accounts in question. We have a workflow that enables accounts that were returned in a search so that is something similar.

![image](https://global.discourse-cdn.com/sailpoint/original/2X/3/31075cc47596671a429c72df52a715abbcf1e00f.png)

Our workflow triggers off aggregation, waits a bit for post aggregation processing to complete and then runs a search query on accounts we want to enable. The list of accounts is then looped through an enabled one at a time.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/6/6311bee8c3e7a4e1d04e5ac482fb69f92d76da6d.png)

Might not be what you are looking for all of these, but if you have to do a handful here or there ongoing, it might be useful.

---

<div class="post-metadata">

**Author:** ![Sai\_Sumanth\_Golla](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@Sai\_Sumanth\_Golla](https://developer.sailpoint.com/discuss/u/Sai_Sumanth_Golla)\
**Post date:** [February 9, 2024, 8:01pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948/4 "2024-02-09T20:01:14Z")

</div>

Thanks for your help ben, but our environment doesn’t have the workflows enabled.

---

<div class="post-metadata">

**Author:** ![BenNelson](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/bennelson/32/6002_2.png) [@BenNelson](https://developer.sailpoint.com/discuss/u/BenNelson)\
**Post date:** [February 9, 2024, 8:44pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948/5 "2024-02-09T20:44:37Z")

</div>

Ok, yeah then I probably would script it like mentioned previously. You could use a PowerShell script like this to do it. Please note that I have not ran in this code in a long time so use at your risk.

```auto
# Specify the path to the file containing account information
$accountsFilePath = "C:\Path\To\Your\Accounts\File.txt"

# Read the accounts from the file
$accounts = Get-Content -Path $accountsFilePath

# Define headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer <TOKEN>")

# Loop through each account in the file
foreach ($account in $accounts) {
    # Create the JSON body for the API call
    $body = @"
    {
      "externalVerificationId": "$account",
      "forceProvisioning": false
    }
"@

    # Construct the API endpoint with the account ID
    $apiEndpoint = "https://sailpoint.api.identitynow.com/beta/accounts/$account/disable"

    # Invoke the REST method for each account
    $response = Invoke-RestMethod -Uri $apiEndpoint -Method 'POST' -Headers $headers -Body $body

    # Display the response (you can customize this part based on your needs)
    $response | ConvertTo-Json
}

```

Good luck

---

<div class="post-metadata">

**Author:** ![Sai\_Sumanth\_Golla](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@Sai\_Sumanth\_Golla](https://developer.sailpoint.com/discuss/u/Sai_Sumanth_Golla)\
**Post date:** [February 23, 2024, 5:01pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948/6 "2024-02-23T17:01:04Z")

</div>

Thanks @BenNelson, it worked

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [April 23, 2024, 5:01pm UTC](https://developer.sailpoint.com/discuss/t/bulk-account-disabling/29948/7 "2024-04-23T17:01:24Z")

</div>

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