Powershell Commands for OnSite Support Activities : Part 7 of Troubleshooting Tools

by New Contributor on ‎2010-12-13 04:31 PM

Lets Get Graphical.

This script is used to create a more graphical representation of a set of iGroups and the Initiators that are registered with them. I got motivated by the great script that creates a visio of the Aggregates and the LUNs and Volumes that are in them. See http://communities.netapp.com/docs/DOC-6411 for more details on what default files need to be in what locations, and how to run the script. The script is as follows,

Script Contents

$shpFile1 = "\NetApp-Logic-Icons.vss"
$shpFile2 = "\NetApp-Equipment-Icons.vss"
$Username  = "administrator"
$Password  = ConvertTo-SecureString "netapp1" -AsPlainText –Force
$Filer  = "10.58.96.222"
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$Password
Connect-NaController $Filer -Credential $cred

function connect-visioobject ($firstObj, $secondObj)
{   $shpConn = $pagObj.Drop($pagObj.Application.ConnectorToolDataObject, 0, 0) 
#// Connect its Begin to the 'From' shape:
$connectBegin = $shpConn.CellsU("BeginX").GlueTo($firstObj.CellsU("PinX"))
#// Connect its End to the 'To' shape:
$connectEnd = $shpConn.CellsU("EndX").GlueTo($secondObj.CellsU("PinX"))
}

function add-visioobject ($mastObj, $item)
{ Write-Host "Adding $item"
# Drop the selected stencil on the active page, with the coordinates x, y
$shpObj = $pagObj.Drop($mastObj, $x, $y)
# Enter text for the object
$shpObj.Text = $item
#Return the visioobject to be used
return $shpObj
}

# Create an instance of Visio and create a document based on the Basic Diagram template.
$AppVisio = New-Object -ComObject Visio.Application
$docsObj = $AppVisio.Documents
$DocObj = $docsObj.Add("Basic Network Diagram.vst")
# Set the active page of the document to page 1
$pagsObj = $AppVisio.ActiveDocument.Pages
$pagObj = $pagsObj.Item(1)
# Load a set of stencils and select one to drop
$stnPath = [system.Environment]::GetFolderPath('MyDocuments') + "\My Shapes"
$stnObj1 = $AppVisio.Documents.Add($stnPath + $shpFile1)
$stnObj2 = $AppVisio.Documents.Add($stnPath + $shpFile2)
$InitiatorObj = $stnObj2.Masters.Item("PAM Card")
$IgroupObj = $stnObj1.Masters.Item("Internal Scrutiny")
$FASObj = $stnObj2.Masters.Item("FAS3000 Double controllers")
$allIgroup = Get-NaIgroup
$y = $allIgroup.Count * 1.50 / 2
$x = 1.50
$FASObj = add-visioobject $FASObj $FASName
$x = 3.50
$y += 2
Foreach ($Igroup in $allIgroup)
{ $Ginfo=      "IGroup Name: "    + $Igroup.InitiatorGroupName + `
   "`r`n IGroup OS Type: " + $Igroup.InitiatorGroupOSType + `
   "`r`n IGroup ALUA On: " + $Igroup.InitiatorGroupALUAEnabled + `
   "`r`n IGroup Type: "    + $Igroup.InitiatorGroupType
$IgroupObj = add-visioobject $IgroupObj $Ginfo
connect-visioobject $FASObj $IgroupObj
$y += 1.5
$allInitiators = $Igroup.initiators
Foreach ($Initiator in $allInitiators)
{  $x += 2.50
   $Info = "Initiator Name: " + $Initiator.InitiatorName
   $InitiatorObj = add-visioobject $InitiatorObj $Info
   connect-visioobject $IGroupObj $InitiatorObj
}
$x = 3.50
$y += 2.50
} # Resize to fit page
$pagObj.ResizeToFitContents()

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to our Code of Conduct and Community Terms of Use DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.