Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Check AD User Replication with while and foreach

$
0
0

Hello scripting experts

I'm not a powershell specialist . I had built a script that create an ad-user and give them permissions to a folder with set-acl. With set-acl i can't set a specific domain Controller so i had the problem when the user that i have just created is not replicated to all AD controllers. So i will check this in the script and wait until the user is replicated. I try this but it doesn't work. What do i wrong?

Import-Module ActiveDirectory $DCs = get-addomain # test list all DC -// write-host $DCs.ReplicaDirectoryServers foreach ($objitem in $DCs.ReplicaDirectoryServers) { write-host 'check on' $objitem while ($Aduser_CHK -ne $NULL) { $Aduser_CHK = (Get-ADUser -Identity thoflo -server $objitem).ObjectClass trap {'User do not exist on all DCs' -f $_.Exception.Message; continue} Start-Sleep -Seconds 1 } }


Thank you for all replies

Florian



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>