Last active
August 2, 2016 14:44
-
-
Save JPRuskin/9e67700b8a526c3d4d7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Begins an Azure DirSync. | |
.Description | |
Contains a function that will connect to a server (defaulting to ADFS01), load the Azure DirSync profile, and kick off a sync. | |
Prompts for creds regardless of account, but can be given credentials to use. | |
.Parameter server | |
The server to connect to. Defaults to ADFS01. | |
.Parameter Credential | |
Credentials to try connecting to the server with. | |
.Example | |
ITG_Force-365ADSync.ps1 | |
Performs a sync, prompting for credentials, using default server. | |
.Example | |
ITG_Force-365ADSync.ps1 -server "TestServer2008" | |
Performs a sync, prompting for credentials, on "TestServer2008" | |
#> | |
param( | |
[PSCredential]$Credential, | |
$Server = 'ADFS01' | |
) | |
if (!$Credential) {$Credential = Get-Credential -Message 'ADFS Sync' -UserName $env:UserName"_admin"} | |
function Invoke-365ADSync($Server, $Credential) { | |
Invoke-Command -ComputerName $Server -Credential $Credential -ScriptBlock { | |
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile 'C:\Program Files\Windows Azure Active Directory Sync\DirSyncConfigShell.psc1' -command 'Start-OnlineCoexistenceSync' | |
} | |
} | |
if ($MyInvocation.InvocationName -NE '.') { Invoke-365ADSync -server $Server -Credential $Credential } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment