Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Powershell Script:
  2.  
  3. $Groups = Get-Content "C:\Scripts\Groups.txt"
  4. $Players = Get-Content "C:\Scripts\Players.txt"
  5.  
  6. Clear-Variable -Name "PlayerGroups"
  7.  
  8. $PlayerGroups = New-Object "System.Collections.Generic.Dictionary[String,String]"
  9.  
  10. foreach($Player in $Players)
  11. {
  12.     $RandomGroup = $Groups[(Get-Random -Maximum ([array]$Groups).count)]
  13.     $PlayerGroups.Add("$player","$RandomGroup")
  14. }
  15.  
  16. Write-Output $PlayerGroups | Sort-Object
  17.  
  18.  
  19. Output:
  20.  
  21. Key     Value
  22. ---     -----
  23. PlayerA GroupB
  24. PlayerB GroupC
  25. PlayerC GroupA
  26. PlayerD GroupE
  27. PlayerE GroupE
  28. PlayerF GroupA
  29. PlayerG GroupB
  30. PlayerH GroupE
  31. PlayerI GroupB
  32. PlayerJ GroupB
  33. PlayerK GroupD
  34. PlayerL GroupE
  35. PlayerM GroupE
  36. PlayerN GroupD
  37. PlayerO GroupD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement