Set the Okta org URL with an Intune platform script

Deploy a PowerShell script through Intune that writes the org URL to the registry on each device.

About this task

An Intune platform script runs once on each device after it succeeds. If it fails, Intune retries at the next three check-ins. To change the org URL, edit the script and upload it again in the script's properties. The changed script runs again on all assigned devices. The script doesn't restore the value if someone deletes it. Intune Remediations can rerun the script on a schedule, but they require Windows Enterprise E3 or E5, Education A3 or A5, or Windows Virtual Desktop Access (VDA) licensing.

For more information, see Add PowerShell Scripts to Windows Devices in Microsoft Intune.

Procedure

  1. Copy the following script into a file named Set-OktaSamOrgUrl.ps1.
    # Okta SAM for Microsoft Edge: set the Okta organization URL
    $OrgUrl = "https://your-org.okta.com"   # <-- Replace with your Okta org URL
    # Do not edit below this line
    $ExtensionId = "ahgjkedohmecdnfgfggeboeccjjaiaif"
    $Key = "HKLM:\SOFTWARE\Policies\Microsoft\Edge\3rdparty\extensions\$ExtensionId\policy"
    if ($OrgUrl -notmatch '^https://[A-Za-z0-9.-]+$') {
        Write-Error "Invalid OrgUrl '$OrgUrl'. Use the form https://yourorg.okta.com with no trailing slash or path."
        exit 1
    }
    try {
        New-Item -Path $Key -Force -ErrorAction Stop | Out-Null
        Set-ItemProperty -Path $Key -Name "orgUrl" -Value $OrgUrl -Type String -ErrorAction Stop
        Write-Output "Okta SAM orgUrl set to $OrgUrl"
        exit 0
    }
    catch {
        Write-Error "Failed to set Okta SAM orgUrl: $_"
        exit 1
    }
  2. Replace the org URL in the $OrgUrl line with yours. Don't add a trailing slash or a path.
  3. Save the file with UTF-8 or ASCII encoding.
  4. In the Intune admin center, go to Devices > Scripts and remediations > Platform scripts.
  5. Select Add, and then select Windows 10 and later.
  6. On Basics, enter a name such as Okta SAM - Edge orgUrl, and then select Next.
  7. On Script settings, upload the script.
  8. Set Run this script using the logged on credentials to No.

    This runs the script as SYSTEM so it can write to the machine-wide registry key.

  9. Set Enforce script signature check to No.

    Set it to Yes only if your org signs scripts.

  10. Set Run script in 64-bit PowerShell host to Yes.

    This avoids 32-bit registry redirection.

  11. Select Next.
  12. Add scope tags if needed, and then select Next.
  13. On Assignments, add the group you used for the certificate and Edge policy profiles, and then select Next.
  14. On Review + add, select Add.

What to do next

Next, complete the steps in Verify the SAM plugin deployment.