function Force-ADSync {
[CmdletBinding()]
Param (
[Parameter(position=0,mandatory=$true)][String]$type
)
switch ($type) {
Delta {
Invoke-Command -ComputerName server.domain.local -ScriptBlock {
Import-Module adsync
Start-ADSyncSyncCycle -PolicyType Delta
}
}
Full {
Invoke-Command -ComputerName server.domain.local -ScriptBlock {
Import-Module adsync
Start-ADSyncSyncCycle -PolicyType Initial
}
}
}
}
Thanks in advance!
Invoke-Command -ComputerName server.domain.local
Enter-PSSession -ComputerName server.domain.local
Import-Module ADSync
[CmdletBinding()]
Param(
[Parameter(position=0,mandatory=$true)]
[ValidateSet('Delta', 'Full')]
[String]$Type,
[string]$ComputerName = 'server.domain.local'
)
Invoke-Command -ComputerName $ComputerName -ArgumentList $type -ScriptBlock {
Param($Type)
If ($Type -eq 'Full') {$Type = 'Initial'}
Import-Module adsync
Start-ADSyncSyncCycle -PolicyType $Type
}
Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.
TRUSTED BY
ASKER