Bij de overgang van Active Directory aanmeldingen naar EntryID aanmeldingen moet voor elke gebruiker een authenticatie email worden ingevuld. Dat kan handmatig, maar bij meer dan 5 gebruikers wordt dat al irritant. Als je in je Active Directory als UserPrincipalName de e-mail adressen hebt staan (wat vaak het geval is) kan het volgende script gebruikt worden wat de gebruikers uit Business Central leest, het juiste AD account daarbij zoekt, het e-mail adres ophaalt en dat invult bij de authenticatieemail in Business Central.

 

$ServerInstance = "Servicenaam"

Get-WindowsCapability -Name RSAT* -Online | Add-WindowsCapability
Install-WindowsFeature RSAT-AD-PowerShell
$ServiceLocation = (get-itemproperty -path HKLM:\SYSTEM\CurrentControlSet\Services\MicrosoftDynamicsNAVServer`$$serverinstance).ImagePath
if ($Servicelocation.indexof('"') -ge 0) {
$ServiceLocation = $ServiceLocation.split('"')[1]
}
$ServiceLocation = Split-path -path $ServiceLocation
if ([string]::IsNullOrWhitespace($ServiceLocation)) {
write-host "Could not locate $ServerInstance"
$ServerInstance = ""
read-host "Press enter to quit script"
return
}
Get-childitem "$ServiceLocation\Microsoft.dynamics.nav.management.dll" -recurse | Import-module -verbose
Get-childitem "$ServiceLocation\Microsoft.dynamics.nav.apps.management.dll" -recurse | Import-module -verbose

$Users=get-navserveruser $ServerInstance | ? WindowsSecurityID -ne "" | ? AuthenticationEmail -eq ""
Foreach ($User in $Users) {
set-navserveruser $ServerInstance -UserName $User.Username -AuthenticationEmail (get-aduser -identity $user.WindowsSecurityID).UserPrincipalName
}