Public/Sync-AAD.ps1
function Invoke-SyncAAD { <# .SYNOPSIS Invoke a delta synchronization between on-premise Active Directory and Azure Active Directory. .EXAMPLE !sync #> [PoshBot.BotCommand( CommandName = 'syncaad', Aliases = ('sync', 'aad', 'sync-aad') )] [cmdletbinding()] param() try { $result = Invoke-Command -ComputerName "sun-aad.sunssc.local" -ScriptBlock { Start-ADSyncSyncCycle -PolicyType Delta } New-PoshBotTextResponse -Text ($result | Out-String) -AsCode } catch { Write-Output "$($_.Exception.Message)" Write-Output "$($_.error.message)" } } |