Hi mark terry,
Please understand that the tag “Microsoft Exchange Online Management” is for general questions related to Exchange Online. For your question about the script which is not supported in our community.
But based on my personal experience, you could try the following script :
$syncedUsers = Import-Csv D:\Users.csv | Select UserPrincipalName
$allUsersSynced = $false
$retryInterval = 60 # seconds to wait before the next retry
while (-not $allUsersSynced) {
$allUsersSynced = $true # Assume all users are synced, and prove otherwise if a user isn't found
foreach ($user in $syncedUsers) {
try {
Get-MsolUser -UserPrincipalName $user.UserPrincipalName -ErrorAction Stop
Write-Host "User $($user.UserPrincipalName) is synced."
}
catch {
# If an error is caught, it means the user is not synced yet.
Write-Host "User $($user.UserPrincipalName) is not synced yet."
$allUsersSynced = $false
}
}
if (-not $allUsersSynced) {
# Wait for some time before rechecking
Write-Host "Waiting for $retryInterval seconds before rechecking..."
Start-Sleep -Seconds $retryInterval
}
}
Write-Host "All users are now synced."