Create Bulk Access Requests in ISC

Thanks to @dernc and @ethompson whose posts helped in creating the PowerShell script.

Below is the modified PowerShell Script which you can use to create Access Request in Bulk.

#sandbox
$ClientID = "XXXXXXXXXXXXXXXXXXXXXXXXX"
$SecretID = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
$pair = "$($ClientID):$($SecretID)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($pair))
$BasicAuth1 = "Basic $encodedCreds"

#Get credentials and encrypt them
$tokenParam = @{
               URI = 'https://my-tenant.api.identitynow.com/oauth/token'
               Body="grant_type=client_credentials"
               Headers = @{'Authorization' = "$BasicAuth1";"Content-Type"='application/x-www-form-urlencoded;application/json;charset=UTF-8'}
               Method = 'POST'
               
}
$tokenResponse = Invoke-RestMethod @tokenParam
$token = $tokenResponse.access_token
$users = @()
$entitlementId = "" 

foreach ($user in $users) {
    $body = @{
        requestedFor   = @(
            $user
        )
        requestType    = "GRANT_ACCESS"
        requestedItems = @(
            [PSCustomObject]@{
                type    = "ENTITLEMENT"
                id      = $entitlementId
                comment = "Assining entitlement to the users as per request from Karan"
            }
        )
    }
    (ConvertTo-Json $body -depth 5)
    
    $params = @{
        method      = "POST"
        uri         = "https://my-tenant.api.identitynow.com/v3/access-requests"
        body        = (ConvertTo-Json $body -Depth 5)
        headers     = @{'Authorization' = "Bearer $token"}
        ContentType = "application/json"
    }
    try {
        $response = Invoke-RestMethod @params
        $response
    }
    catch {
        Write-Host $response
        Write-Host $_.Exception.Message  -ForegroundColor Red
        Write-Host $_.Exception.ItemName  -ForegroundColor Red
    }
}
3 Likes

Hi @karan_1984,

Helpful post. Thank you for sharing the script will us all. Perhaps you wanted your post to be in “ISC Community Knowledge Base” where I think your post fits better.

I agree! @karan_1984 Try posting it here with better representation of the script, perhaps with more details and explanation: ISC Community Knowledge Base - SailPoint Developer Community

Thanks for the in put Amar I have posted in “ISC Community Knowledge Base”.

1 Like

HI Sushant,

I have posted in “ISC Community Knowledge Base”.

1 Like