修改description这个属性,在两台域控上观察这个属性变化的时间戳。顺便搞搞清楚两种循环的区别,DoUntil是条件满足才终止,DoWhile是条件不满足即终止。
Do...Until写法:
Set-ADUser -Server corp-dc5-was -Identity 'CN=name1,OU=users,DC=corp,DC=contoso,DC=com' -Description 'Admin Account 1' $start = Get-Date Write-Host -NoNewline 'Syncing' do { Write-Host -NoNewline '.' Start-Sleep -Seconds 1 } until ( (Get-ADUser -Server corp-dc1-chn -Identity 'CN=name1,OU=users,DC=corp,DC=contoso,DC=com' -Properties description).description -eq 'Admin Account 1' ) $end = Get-Date
"`nStart on: $start"
"End on: $end" "Interval: " + ($end - $start)
Do...While写法:
$dn = 'CN=name1,OU=users,DC=contoso,DC=com' Set-ADUser -Server corp-dc5-was -Identity $dn -Description 'Admin Account 1' $start = Get-Date Write-Host -NoNewline 'Syncing' do { Write-Host -NoNewline '.' Start-Sleep -Seconds 1 } while ( (Get-ADUser -Server corp-dc1-chn -Identity $dn -Properties description).description -eq 'Admin Account' ) $end = Get-Date "`nStart on: $start" "End on: $end" "Interval: " + ($end - $start)