MuratYildirimoglu

Creating Sopranos Family Tree Using Powershell

May 12th, 2021
15
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Install-Module PSWriteHTML
  2.  
  3.  
  4.  
  5. $Family=@(“Junior Soprano”,”Boss”,”Tony”,”Underboss”,”Sylvio”,”consigliere”,”Pauli”,”Capo”,”Bacala”,”capo”,”Furio”,”Soldier”,”Eugene”,”Soldier”,”Christopher”,”Soldier”,”Vito”,”Soldier”,”mike”,”capo”)
  6. $nameboss=”
  7. $nameunderboss=”
  8. $nameconsigliere=”
  9. $namecapo=@()
  10. $namesoldier=@()
  11. $length=$Family.length
  12.  
  13. New-HTML -Online -FilePath $PSScriptRoot\MyDiagram.html {
  14. New-HTMLDiagram {
  15. New-DiagramOptionsLayout -HierarchicalEnabled $true
  16. New-DiagramOptionsPhysics -Enabled $true -HierarchicalRepulsionAvoidOverlap 1 -HierarchicalRepulsionNodeDistance 100
  17. $i=0
  18. while ($i -lt $length) {
  19.  
  20. switch ($family[$i+1]){
  21. “boss” {
  22. New-DiagramNode -Label $family[$i] -level 0
  23. $nameboss=$family[$i]
  24. }
  25. “underboss” {
  26. New-DiagramNode -Label $family[$i] -level 1
  27. $nameunderboss=$family[$i]
  28. }
  29. “consigliere” {
  30. New-DiagramNode -Label $family[$i] -level 1
  31. $nameconsigliere=$family[$i]
  32. }
  33. “capo” {
  34. New-DiagramNode -Label $family[$i] -level 2
  35. $namecapo=$namecapo+$family[$i]
  36. }
  37. “soldier” {
  38. New-DiagramNode -Label $family[$i] -level 3
  39. $namesoldier=$namesoldier+$family[$i]
  40. }
  41. } #endof switch
  42.  
  43. $i=$i+2
  44. } #endoof while
  45.  
  46. New-DiagramLink -From $nameunderboss -To $nameboss -ArrowsToEnabled
  47. New-DiagramLink -From $nameconsigliere -To $nameunderboss -ArrowsToEnabled
  48. $namecapo | foreach { New-DiagramLink -From $_ -To $nameunderboss -ArrowsToEnabled}
  49. $namesoldier | foreach {
  50. $lengthCapo=$namecapo.length
  51. $capoDestinationIndex=get-random -minimum 0 -maximum $lengthCapo
  52. New-DiagramLink -From $_ -To $namecapo[$capoDestinationIndex] -ArrowsToEnabled
  53. }
  54.  
  55. }
  56.  
  57. } -ShowHTML
RAW Paste Data