Set attributes of other applications when After Modify script of Active Directory is successful

Hi,

I want to send acknowledgement by setting an attribute in okta when After Modify script of Active Directory is successful . Based on Powershell module of Identity now wrote some script. Please let me know if it works.

			   $res1 = Invoke-Expression \"\\networklocation\folder\Test.ps1 -Start\"
                   Add-content $Logfile -value \"$Stamp Successfully executed Test.ps1\"
				 Add-content $Logfile -value \"$Stamp Result ::: $res1 \"
$user = Search-IdentityNowUsers -query \"@accounts(accountId:$mail)\"
$userIndirectAccounts = $user.accounts | select-object | where-object {($_.source.type.contains(\"Okta\"))}
$account = $userIndirectAccounts[0].id 
				 if($res1 -like '*Success*'){ 
			$update = @{\"ADOkta_disable_delete\" = \"Terminate-Complete\"} | ConvertTo-Json 
			
			$v3Token = Get-IdentityNowAuth

if ($v3Token.access_token) {
    try {                         
        $updateAccount = Invoke-RestMethod -Method Patch -Uri \"https://apiurl/v2/accounts/$($account)?org=$($IdentityNowConfiguration.orgName)\" -Headers @{Authorization = \"$($v3Token.token_type) $($v3Token.access_token)\"; \"Content-Type\" = \"application/json\"} -Body $update
        return $updateAccount           
    }
    catch {
        Write-Error \"User not found. Update failed. $($_)\" 
    }
}
else {
    Write-Error \"Authentication Failed. Check your AdminCredential and v3 API ClientID and ClientSecret. $($_)\"
    return $v3Token
}