我对PowerShell脚本工作示例感兴趣,它只询问Active Directory UserName和Domain以及新密码作为输入参数:

......,和 forces this change as (fast as possible) to replicate with the entire forest.

此脚本的目的是让Exchange,SkypeforBusiness(和其他系统)在整个林中识别此密码更改;因此,在密码更改发送到单个DC后,这些系统不会立即提示登录用户输入新密码(即使在用户注销并使用新密码成功重新登录到他们的工作站之后) . 也许,强制复制到用户站点/域中的桥头服务器就足够了?

我知道如何使用AD域中的以下3行更改用户密码 . 但是,我不确定如何尽快在整个森林中复制这种变化 .

$Domain = "DomainName"
$UserID = "BillKP"
$newpwd = "pass123"

$DC = Get-ADDomain $Domain | select -ExpandProperty InfrastructureMaster
Set-ADAccountPassword $UserID -NewPassword $newpwd -Reset -Server $DC

我在 Sync-ADObject 找到了以下示例 . 但是,我不确定如何在上面的脚本中使用它(假设我上面提到的意图) .

PS: 我没有't want to lock up the PowerShell console when forcing replication of this user'森林的新密码 .

Get-ADDomainController -filter * | ForEach {Sync-ADObject -object "CN=James, OU=BusinessUsers, DC=Test, DC=Local" -source NKAD1 -destination $_.hostname}

提前致谢!