Skip to content

Instantly share code, notes, and snippets.

@FH-Inway
Last active December 31, 2023 16:10
Show Gist options
  • Save FH-Inway/5b5e86a4eb7ee8cd1670c6a8599d8f1e to your computer and use it in GitHub Desktop.
Save FH-Inway/5b5e86a4eb7ee8cd1670c6a8599d8f1e to your computer and use it in GitHub Desktop.
Adds an Entra app registration id as audienceUri in a D365FO wif.config
# Adds an audienceUri entry to the WIF configuration file
# Original script: https://gist.github.com/FH-Inway/5b5e86a4eb7ee8cd1670c6a8599d8f1e
param(
[Parameter(Mandatory)]
[Alias('AppId', 'ClientId')]
[string]$AudienceUri,
[string]$WifConfigPath = 'K:\AosService\webroot\wif.config'
)
[xml]$wifConfig = Get-Content $WifConfigPath
$audienceUris = $wifConfig.'system.identityModel'.'identityConfiguration'.'securityTokenHandlers'.'securityTokenHandlerConfiguration'.'audienceUris'
$audienceUriElement = $wifConfig.CreateElement('add')
$audienceUriElement.SetAttribute('value', "spn:$AudienceUri")
$audienceUris.PrependChild($audienceUriElement)
$wifConfig.Save($WifConfigPath)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment