Advertisement
Guest User

SCOM MP Class Visualizer 0.3

a guest
Apr 5th, 2013
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param(
  2.     [string[]]$ClassNames,
  3.     [switch]$IncludeRelationship,
  4.     [switch]$Help
  5. )
  6.  
  7. if (-not $ClassNames -and -not $help){
  8.     Write-Error "Необходимо указать параметр $ClassNames"
  9.     $Help = $true
  10. }
  11.  
  12. if ($help){
  13.     Write-Host "SCOM MP Class Visualizer script, version 0.3"
  14.     Write-Host "http://gexeg.blogspot.com"
  15.     Write-Host "Параметры: "
  16.     Write-Host "   -Help                    : вывод справочной информации "
  17.     Write-Host "   -ClassNames <[string[]]> : необходимо указать массив классов,"
  18.     Write-Host "                              по которым будет строиться дерево классов"
  19.     Write-Host "   -IncludeRelationship     : Включить отображение связей между классами`n"
  20.     Write-Host "Примеры использования:"
  21.     Write-Host "1) .\SCOMDrawClassTree.ps1 -ClassNames ""Microsoft.Windows.Server.2008.AD.DomainControllerRole"", ""Microsoft.Windows.Server.2008.AD.DC.KDC"""
  22.     Write-Host "`n2) .\SCOMDrawClassTree.ps1 -ClassNames ""Microsoft.Windows.Server.2008.AD.DomainControllerRole"""
  23.     Write-Host "`n3) `$classNames = Get-SCOMClass -ManagementPack (Get-ScomManagementPack -Name ""Microsoft.Windows.Server.AD.Library"") | foreach {`$_.Name}"
  24.     Write-Host "   .\SCOMDrawClassTree.ps1 -ClassNames `$classNames"
  25.     Write-Host "`n4) .\SCOMDrawClassTree.ps1 -ClassNames ""Microsoft.Windows.Server.2008.AD.DomainControllerRole"" -IncludeRelationship"
  26.     exit
  27. }
  28.  
  29. if (-not (Get-Module OperationsManager)){
  30.     Import-Module OperationsManager
  31. }
  32.  
  33. [hashtable]$classes = @{}
  34. [hashtable]$shapes = @{}
  35.  
  36. #Const VisSectionIndices
  37. $visSectionObject = 1
  38. $visSectionParagraph = 4
  39. $visSectionProp = 243
  40.  
  41. #Const VisRowIndices
  42. $visRowXFormOut = 1
  43. $visRowTextXForm = 12
  44. $visRowPageLayout = 24
  45. $visRowLast = -2
  46. $visRowFill = 3
  47. $visRowLine = 2
  48.  
  49. #Const
  50. $visXFormPinX = 0
  51. $visXFormPinY = 1
  52. $visXFormWidth = 2
  53. $visPLOPlaceStyle = 8
  54. $visPLORouteStyle = 9
  55. $visPLOLineRouteExt = 29
  56. $visCustPropsLabel = 2
  57. $visCustPropsType = 5
  58. $visCustPropsValue = 0
  59. $visFillForegnd = 0
  60. $visFillBkgnd = 1
  61. $visLineColor = 1
  62. $visLinePattern = 2
  63. $visLineEndArrow = 6
  64.  
  65. $visTagDefault = 0
  66. $visLayoutIncrSpace = 2
  67. $visLayoutHorzAlignNone = 0
  68. $visLayoutVertAlignNone = 0
  69. $visMillimeters = 70
  70.  
  71.  
  72. function VisioResizeShape($shape){
  73.     $shape.CellsSRC($visSectionObject, $visRowXFormOut, 2).FormulaU = "10 mm"
  74.     $shape.CellsSRC($visSectionObject, $visRowXFormOut, 3).FormulaU = "10 mm"
  75. }
  76.  
  77. function VisioSetConStyle($con){
  78.     $con.CellsSRC($visSectionObject,2,0).FormulaU = "0.25 pt"
  79.     $con.CellsSRC($visSectionObject,23,19).FormulaU = "0"
  80. }
  81.  
  82. function VisioSetText($shape, $text){
  83.     $chars = $shape.Characters
  84.     $chars.Begin = 0
  85.     $chars.Begin = 0
  86.     $chars.Text = $text
  87.  
  88.    
  89.     $shape.CellsSRC($visSectionObject,11,4).FormulaU = "0"
  90.     $shape.CellsSRC($visSectionParagraph,0,6).FormulaU = "0"
  91.    
  92.     $shape.CellsSRC($visSectionObject,$visRowTextXForm,$visXFormWidth).FormulaU = "5"
  93.     $shape.CellsSRC($visSectionObject,$visRowTextXForm,$visXFormPinX).FormulaU = "3"
  94.     #$shape.CellsSRC($visSectionObject,$visRowTextXForm,$visXFormPinY).FormulaU = "Height*0.5"
  95.    
  96.     #$shape.CellsSRC($visSectionObject,$visRowTextXForm, 4).FormulaU = "-1"
  97.     #$shape.CellsSRC($visSectionObject,$visRowTextXForm, 5).FormulaU = "TxtHeight*2"
  98.  
  99. }
  100.  
  101. function VisioAddDataRow($shape, $Name, $Value){
  102.     $row = $shape.AddRow($visSectionProp, $visRowLast, $visTagDefault)
  103.     $shape.CellsSRC($visSectionProp, $row, $visCustPropsLabel).FormulaU = """$Name"""
  104.     $shape.CellsSRC($visSectionProp, $row, $visCustPropsType).FormulaU = "0"
  105.    
  106.     if ($Value -and $Value.ToString().Contains('"')){
  107.         $Value = $Value.ToString().Replace('"',"'")
  108.     }
  109.    
  110.     $shape.CellsSRC($visSectionProp, $row, $visCustPropsValue).FormulaU = """$Value"""
  111. }
  112.  
  113. function VisioRearIcons(){
  114.     $page.PageSheet.CellsSRC($visSectionObject, $visRowPageLayout, $visPLOPlaceStyle).FormulaForceU = "7"
  115.     $page.PageSheet.CellsSRC($visSectionObject, $visRowPageLayout, $visPLORouteStyle).FormulaForceU = "3"
  116.     $page.Layout()
  117.     $visio.ActiveWindow.SelectAll()
  118.     $visio.ActiveWindow.Selection.LayoutIncremental($visLayoutIncrSpace,
  119.         $visLayoutHorzAlignNone, $visLayoutVertAlignNone, 70, 8, $visMillimeters)
  120.     $page.Shapes.ItemFromID(0).CellsSRC($visSectionObject, $visRowPageLayout, $visPLOLineRouteExt).FormulaU = "2"
  121. }
  122.  
  123. function VisioRearIcons2(){
  124.     $page.PageSheet.CellsSRC($visSectionObject, $visRowPageLayout, $visPLOPlaceStyle).FormulaForceU = "17"
  125.     $page.PageSheet.CellsSRC($visSectionObject, $visRowPageLayout, $visPLORouteStyle).FormulaForceU = "3"
  126.     $page.Layout()
  127.     $visio.ActiveWindow.SelectAll()
  128.     $visio.ActiveWindow.Selection.LayoutIncremental($visLayoutIncrSpace,
  129.         $visLayoutHorzAlignNone, $visLayoutVertAlignNone, 70, 8, $visMillimeters)
  130.     $page.Shapes.ItemFromID(0).CellsSRC($visSectionObject, $visRowPageLayout, $visPLOLineRouteExt).FormulaU = "2"
  131. }
  132.  
  133. function VisioCreateRelConnector($From, $To, $RelType){
  134.     $con = $page.DrawLine(0.1, 0.1, 0.2, 0.2)
  135.    
  136.     $con.CellsU("BeginX").GlueTo($From.CellsSRC(7,0,0))
  137.     $con.CellsU("EndX").GlueTo($To.CellsSRC(7,0,0))
  138.    
  139.     switch ($RelType) {
  140.         "System.Containment" {
  141.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,255))"
  142.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "1"
  143.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  144.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  145.             break
  146.         }
  147.         "System.Hosting" {
  148.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,255))"
  149.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "2"
  150.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  151.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  152.             break
  153.         }
  154.         "System.Reference" {
  155.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(255,0,0))"
  156.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "2"
  157.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  158.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  159.             break
  160.         }
  161.         "System.Membership" {
  162.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,0))"
  163.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "2"
  164.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  165.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  166.             break
  167.         }
  168.         default {
  169.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,0))"
  170.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "1"
  171.             $con.CellsSRC($visSectionObject,$visRowLine,0).FormulaU = "0.25 pt"
  172.         }
  173.     }
  174.     return $con
  175. }
  176.  
  177. function VisioCreateHConnector($ConnectorShape, $From, $To, $RelType){
  178.     $con = $page.Drop($ConnectorShape, 1, 1)
  179.    
  180.     $con.CellsU("BeginX").GlueTo($From.CellsSRC(7,0,0))
  181.     $con.CellsU("EndX").GlueTo($To.CellsSRC(7,5,0))
  182.    
  183.     switch ($RelType) {
  184.         "System.Containment" {
  185.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,255))"
  186.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "1"
  187.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  188.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  189.             break
  190.         }
  191.         "System.Hosting" {
  192.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,255))"
  193.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "2"
  194.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  195.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  196.             break
  197.         }
  198.         "System.Reference" {
  199.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(255,0,0))"
  200.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "2"
  201.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  202.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  203.             break
  204.         }
  205.         "System.Membership" {
  206.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,0))"
  207.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "2"
  208.             $con.CellsSRC($visSectionObject, $visRowLine,0).FormulaU = "0.25 pt"
  209.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineEndArrow).FormulaU = "13"
  210.             break
  211.         }
  212.         default {
  213.             $con.CellsSRC($visSectionObject, $visRowLine, $visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,0))"
  214.             $con.CellsSRC($visSectionObject, $visRowLine, $visLinePattern).FormulaU = "1"
  215.             $con.CellsSRC($visSectionObject,$visRowLine,0).FormulaU = "0.25 pt"
  216.         }
  217.     }
  218.     return $con
  219. }
  220.  
  221. function PopulateClassTree($ClassID){
  222.     while ($ClassID){
  223.         $obj = Get-SCOMClass -Id $ClassID
  224.         if ($obj){
  225.             $ClassID = $obj.Base.Id
  226.             $obj | add-member -Name ParentID -MemberType NoteProperty -Value $ClassID
  227.             $classes[$obj.Id] = $obj
  228.             if (-not $ClassID){
  229.                 break
  230.             }
  231.         }
  232.     }
  233. }
  234.  
  235. function PopulateAttr($Shape, $ClassObj){
  236.     VisioAddDataRow -shape $Shape -Name "::::::::Class Properties::::" -Value ":::::::::::::::"
  237.     VisioAddDataRow -shape $Shape -Name "Abstract" -Value $classObj.Abstract
  238.     VisioAddDataRow -shape $Shape -Name "Accessibility" -Value $classObj.Accessibility
  239.     VisioAddDataRow -shape $Shape -Name "Extension" -Value $classObj.Extension
  240.     VisioAddDataRow -shape $Shape -Name "Hosted" -Value $classObj.Hosted
  241.     VisioAddDataRow -shape $Shape -Name "Singleton" -Value $classObj.Singleton
  242.     VisioAddDataRow -shape $Shape -Name "Description" -Value $classObj.Description
  243.    
  244.     if ($ClassObj.PropertyCollection.Count -gt 0){
  245.         VisioAddDataRow -shape $Shape -Name "::::::::Attributes::::" -Value ":::::::::::::::"
  246.         $ClassObj.PropertyCollection | sort Name | foreach {
  247.             if ($_.Key -eq $true) { $isKey = "Key" } else { $isKey=$null }
  248.             if ($_.Required -eq $true) { $Required = "Mandatory" } else { $Required = "Optional"}
  249.             $propVal = [string]::Join(",", @($_.SystemType, $Required, $isKey))
  250.             VisioAddDataRow -shape $Shape -Name $_.Name -Value $propVal
  251.         }
  252.     }
  253. }
  254.  
  255. function PopulateBaseAttr($shape, $classObj){
  256.     if ($classObj.ParentID){
  257.         $attribs = @()
  258.        
  259.         while($classObj.ParentID){
  260.             $classObj = $classes[$classObj.ParentID]
  261.             if ($ClassObj.PropertyCollection.Count -gt 0){
  262.                 VisioAddDataRow -shape $Shape -Name ":::$($ClassObj.Name)::" -Value ":Attributes::::"
  263.                 $ClassObj.PropertyCollection | sort Name | foreach {
  264.                 if ($_.Key -eq $true) { $isKey = "Key" } else { $isKey=$null }
  265.                 if ($_.Required -eq $true) { $Required = "Mandatory" } else { $Required = "Optional"}
  266.                 $propVal = [string]::Join(",", @($_.SystemType, $Required, $isKey))
  267.                 VisioAddDataRow -shape $Shape -Name $_.Name -Value $propVal
  268.                 }
  269.             }
  270.         }
  271.     }
  272. }
  273.  
  274. function PopulateRelAttr($shape, $RelObj){
  275.     VisioAddDataRow -shape $shape -Name "RelName" -Value $RelObj.PSBase.Name
  276.     VisioAddDataRow -shape $shape -Name "::::::::Rel Properties::::" -Value ":::::::::::::::"
  277.     VisioAddDataRow -shape $shape -Name "Source" -Value ((Get-SCOMClass -Id $RelObj.PSBase.Source.Type.Id).Name)
  278.     VisioAddDataRow -shape $shape -Name "Target" -Value ((Get-SCOMClass -Id $RelObj.PSBase.Target.Type.Id).Name)
  279.     VisioAddDataRow -shape $shape -Name "DisplayName" -Value $RelObj.PSBase.DisplayName
  280.     VisioAddDataRow -shape $shape -Name "Description" -Value $RelObj.PSBase.Description
  281.     VisioAddDataRow -shape $shape -Name "ManagementPack" -Value $RelObj.PSBase.Identifier.Domain[0]
  282.     VisioAddDataRow -shape $shape -Name "RelType" -Value (GetRelType -RelObj $RelObj)
  283.     VisioAddDataRow -shape $shape -Name "Accessibility" -Value $RelObj.PSBase.Accessibility
  284.    
  285.     if ($RelObj.PSBase.PropertyCollection.Count -gt 0){
  286.         VisioAddDataRow -shape $Shape -Name "::::::::Attributes::::" -Value ":::::::::::::::"
  287.         $RelObj.PSBase.PropertyCollection | sort Name | foreach {
  288.             if ($_.Key -eq $true) { $isKey = "Key" } else { $isKey=$null }
  289.             if ($_.Required -eq $true) { $Required = "Mandatory" } else { $Required = "Optional"}
  290.             $propVal = [string]::Join(",", @($_.SystemType, $Required, $isKey))
  291.             VisioAddDataRow -shape $Shape -Name $_.Name -Value $propVal
  292.         }
  293.     }
  294. }
  295.  
  296. function PopulateRelBaseAttr($shape, $RelObj){
  297.     $BaseRels = $RelObj.GetBaseTypes()
  298.    
  299.     if ($BaseRels.Count -gt 0){
  300.         foreach ($baseRel in $BaseRels){
  301.             if ($baseRel.PSBase.PropertyCollection.Count -gt 0){
  302.                 VisioAddDataRow -shape $Shape -Name ":::$($baseRel.PSBase.Name)::" -Value ":Attributes::::"
  303.                 $baseRel.PSBase.PropertyCollection | sort Name | foreach {
  304.                     if ($_.Key -eq $true) { $isKey = "Key" } else { $isKey=$null }
  305.                     if ($_.Required -eq $true) { $Required = "Mandatory" } else { $Required = "Optional"}
  306.                     $propVal = [string]::Join(",", @($_.SystemType, $Required, $isKey))
  307.                     VisioAddDataRow -shape $Shape -Name $_.Name -Value $propVal
  308.                 }
  309.             }
  310.         }
  311.     }
  312. }
  313.  
  314. function GetRelType($RelObj){
  315.     $BaseRels = $RelObj.GetBaseTypes() | select -Last 4 | foreach {$_.PSBase.Name}
  316.     if ($BaseRels -contains "System.Hosting"){
  317.         return "System.Hosting"
  318.     }
  319.     elseif($BaseRels -contains "System.Membership") {
  320.         return "System.Membership"
  321.     }
  322.     elseif($BaseRels -contains "System.Containment"){
  323.         return "System.Containment"
  324.     }
  325.     else {
  326.         return "System.Reference"
  327.     }
  328. }
  329.  
  330. $initVisio = {
  331.     Write-Host "Создание приложения Visio"
  332.     $visio = New-Object -ComObject Visio.Application
  333.     $visio.Visible = $false
  334.     $visio.Documents.Add("BASICD_M.VST") | Out-Null
  335.     $doc = $visio.Documents.Item(1)
  336.     $page = $doc.Pages.Item(1)
  337.     $Stensils = $visio.Documents.Item("BASIC_M.VSS")
  338.     $pentagon = $Stensils.Masters.ItemU("Pentagon")
  339.     $dyncon = $Stensils.Masters.ItemU("Dynamic connector")
  340. }
  341.  
  342. $unInitVisio = {
  343.     $visio.Visible = $true
  344.     Write-Host "Переключитесь в Visio и сохраните сформированный документ."
  345.     $visio.quit()
  346.     $page = $null
  347.     $doc = $null
  348.     $visio = $null
  349. }
  350.  
  351. . $initVisio
  352.  
  353. [hashtable]$rels = @{}
  354.  
  355. foreach ($className in $ClassNames){
  356.     Write-Host "Обрабатываем класс $className"
  357.     $classObj = Get-SCOMClass -Name $className
  358.     Write-Host "Заполняем дерево классов"
  359.     PopulateClassTree -ClassID $classObj.ID
  360. }
  361.  
  362. Write-Host "Отрисовка объектов"
  363. $classes.Keys | foreach {
  364.     $shape = $page.Drop($pentagon, 1,1)
  365.     $shape.Name = $classes[$_].Name
  366.    
  367.     if ($classes[$_].Singleton -eq $true){
  368.         $shape.CellsSRC($visSectionObject, $visRowFill, $visFillBkgnd).FormulaU = "THEMEGUARD(MSOTINT(THEME(""LineColor""),80))"
  369.     }
  370.     elseif ($classes[$_].Abstract -eq $false){
  371.         $shape.CellsSRC($visSectionObject, $visRowFill, $visFillBkgnd).FormulaU = "THEMEGUARD(MSOTINT(THEME(""AccentColor4""),40))"
  372.     }
  373.    
  374.     VisioResizeShape -shape $shape
  375.     VisioSetText -shape $shape -text ("$($classes[$_].Name)`n$($classes[$_].DisplayName)`n$($classes[$_].ManagementPackName)")
  376.     PopulateAttr -shape $shape -ClassObj $classes[$_]
  377.     PopulateBaseAttr -shape $shape -ClassObj $classes[$_]
  378.     $shapes[$_] = $shape
  379. }
  380.  
  381. foreach ($class in $classes.Keys){
  382.     if (-not $classes[$class].ParentID){
  383.         continue
  384.     }
  385.    
  386.     $con = $page.Drop($dyncon, 1,1)
  387.     $shapeTo = $shapes[$class]
  388.     $shapeFrom = $shapes[$classes[$class].ParentID]
  389.     $con.CellsU("BeginX").GlueTo($shapeFrom.CellsSRC(7,0,0))
  390.     $con.CellsU("EndX").GlueTo($shapeTo.CellsSRC(7,5,0))
  391.     VisioSetConStyle -con $con
  392. }
  393.  
  394. $relProcess = {
  395. param([String]$RType)
  396.  
  397. Write-Host "Обрабатываем связи"
  398.     $rels.Values | foreach {
  399.         if (-not $shapes.ContainsKey($_.$RType.Type.Id)){
  400.             $classObj = Get-SCOMClass -Id $_.$RType.Type.Id
  401.            
  402.             $shape = $page.Drop($pentagon, 1,1)
  403.             $shape.Name = $classObj.Name
  404.    
  405.             if ($classObj.Singleton -eq $true){
  406.                 $shape.CellsSRC($visSectionObject, $visRowFill, $visFillBkgnd).FormulaU = "THEMEGUARD(MSOTINT(THEME(""LineColor""),80))"
  407.             }
  408.             elseif ($classObj.Abstract -eq $false){
  409.                 $shape.CellsSRC($visSectionObject, $visRowFill, $visFillBkgnd).FormulaU = "THEMEGUARD(MSOTINT(THEME(""AccentColor4""),40))"
  410.             }
  411.    
  412.             VisioResizeShape -shape $shape
  413.             VisioSetText -shape $shape -text ("$($classObj.Name)`n$($classObj.DisplayName)`n$($classObj.ManagementPackName)")
  414.             PopulateAttr -shape $shape -ClassObj $classObj
  415.             #PopulateBaseAttr -shape $shape -ClassObj $classes[$_]
  416.             $shapes[$classObj.Id] = $shape
  417.         }
  418.     }
  419.    
  420.     $rels.Values | foreach {
  421.         $RelType = GetRelType -RelObj $_
  422.         if ($_.Source.Type.Id -eq $_.Target.Type.Id){
  423.             $con = VisioCreateHConnector -ConnectorShape $dyncon -From $shapes[$_.Source.Type.Id] -To $shapes[$_.Target.Type.Id] -RelType $RelType
  424.         }
  425.         else {
  426.             $con = VisioCreateRelConnector -From $shapes[$_.Source.Type.Id] -To $shapes[$_.Target.Type.Id] -RelType $RelType
  427.         }
  428.         $con.Name = $_.PSBase.Name
  429.         PopulateRelAttr -Shape $con -RelObj $_
  430.         PopulateRelBaseAttr -Shape $con -RelObj $_
  431.     }
  432. }
  433.  
  434. if ($IncludeRelationship){
  435.     Write-Host "Получаем связи"
  436.     #Source
  437.     [hashtable]$rels = @{}
  438.     $classes.Keys | foreach {
  439.         Get-SCRelationship -Source $classes[$_] | foreach {
  440.             $rels[$_.PSBase.Name] = $_
  441.         }
  442.     }
  443.    
  444.     . $relProcess -Rtype "Target"
  445.    
  446.     #Target
  447.     [hashtable]$rels = @{}
  448.     $classes.Keys | foreach {
  449.         Get-SCRelationship -Target $classes[$_] | where {$_.PSBase.Source.Type.ID -ne $_.PSBase.Target.Type.ID} | foreach {
  450.             $rels[$_.PSBase.Name] = $_
  451.         }
  452.     }
  453.    
  454.     . $relProcess -Rtype "Source"
  455. }  
  456.  
  457. if ($IncludeRelationship){
  458.     VisioRearIcons2
  459. }
  460. else {
  461.     VisioRearIcons
  462. }
  463.  
  464. Write-Host "Отрисовка объектов закончена"
  465. . $unInitVisio
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement