This PowerShell script can be setup to run as a Windows Scheduled task to automatically sync attributes to an Okta App. This automates the process of logging into the Okta Admin dashboard, and selecting the “Force Sync” button located under “Provisioning” for an app:

Values for “$TARGETIDENTIFIER” and “$SOURCEIDENTIFIER” can be found using a suitable trace application (e.g. SAML Tracer for Firefox):

Requirements:
Okta PSModule (https://github.com/mbegan/Okta-PSModule)
API Token created (Security > API > Token > Create Token):

Script
<#
.SYNOPSIS
Script to invoke the "Force Sync" function in Okta
.DESCRIPTION
The Force Sync function is used to resynchronise/re-apply profile attributes to an Okta App
.INPUTS
No inputs required.
.OUTPUTS
Logs output of script in .\Logs subdirectory
.NOTES
Written by Tom Edwards
#>
$logfile = ".\logs\$(get-date -f yyyyddMM).txt"
$SOURCEIDENTIFIER = ""
$TARGETIDENTIFIER = ""
$ErrorActionPreference = "Continue"
Start-Transcript -Path $logfile -Append
Write-host "Invoking..."
Connect-Okta "APIKEYHERE" "https://YOUROKTATENANT.okta-emea.com"
invoke-method -method PUT "/api/internal/v1/mappings/reapply?source=$SOURCEIDENTIFIER&target=$TARGETIDENTIFIER"
Write-host "End of script."
Stop-Transcript
