Cloud Articles and Resources
Cloud Articles and Resources
Hy all
Here is a simple but powerfull POSH script for VISIO your C-Mode config.
You need the have the latest release of PowerShell 1.7 and MS Office VISIO 2010.
Sample Picture:
#Copyright: Marc Hofstetter / NetApp / 2012 / version 0.75
#POWERSHELL SCRIPT VISIO YOUR C-MODE CONFIG
#Import Data ONTAP PowerShell Toolkit
Import-Module DataONTAP
#VISIO SHAPES for DRAWING
$shpFile1 = "\NetApp-Logic-Icons.vss"
$shpFile2 = "\NetApp-Equipment-Icons.vss"
$shpFile3 = "\NetApp-Icons-2.vss"
$shpFile4 = "\NetApp-Essentials.vss"
#VISIO Function for the Connection-of-objects
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"))
}
#VISIO Function for adding the object into the drawing
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\NetApp\"
$stnObj1 = $AppVisio.Documents.Add($stnPath + $shpFile1)
$FlexVOLObj = $stnObj1.Masters.Item("FlexVol")
$AggrObj = $stnObj1.Masters.Item("Raid Grp Aggregate Storage")
$LUNObj = $stnObj1.Masters.Item("Cylinder")
#Define FAS-Controller Object
$stnObj2 = $AppVisio.Documents.Add($stnPath + $shpFile2)
$FASObj = $stnObj2.Masters.Item("FAS3000")
#Define VServer Object
$stnObj2 = $AppVisio.Documents.Add($stnPath + $shpFile3)
$VServerObj = $stnObj2.Masters.Item("WorkGroup Servers")
#Defien NetApp Frame Obejct
$stnObj4 = $AppVisio.Documents.Add($stnPath + $shpFile4)
$FrameObject = $stnObj4.Masters.Item("Small Title min margin")
$FrameObj = add-visioobject $FrameObject $nodeInfo
#Get Host Name to Connect to
$FASName = read-host "Enter the FQDN of your NetApp C-MODE Cluster"
If ($FASName -eq "") { Write-Host "No selection made, script now exiting." ; exit }
$USERName = read-host "Enter the username for accessing the C-MODE Cluster"
If ($USERName -eq "") { Write-Host "No input made, script now exiting." ; exit }
#HERE WE GO - GET ALL STORAGE DETAILS - using MHOFSTET CRED
Connect-NcController -Name $FASName -Credential $USERName
$allNODES = Get-NcNode
$allVServers = Get-NcVserver
$allAGGR = Get-NcAggr
$allVOLS = Get-NcVol
#Set Start Locations of Objects
$x = 1
$y = 1
#DRAW ALL PHYSICAL-NODES
Foreach ($node in $allNodes) {
$y += 1
$nodeInfo = "NODE: " + $node
$nodeObj = add-visioobject $FASObj $nodeInfo
#DRAW ALL AGGR for physical NODES
Foreach ($aggr in $allAGGR) {
If ($aggr.Nodes -eq $node) {
$x = 2
$y += 1.5
$aggrInfo = "AGGREGATE: " + $aggr.Name
$aggrObj = add-visioobject $AggrObj $aggrInfo
connect-visioobject $nodeObj $aggrObj
}
# GET ROOT VOL for NODE
$allVOLS2 = Get-NcVol -Vserver $node
foreach ($vol in $allVols2) {
if ($vol.Vserver -eq $aggr.AggrOwnershipAttributes.HomeName -and $vol.VolumeIdAttributes.ContainingAggregateName -eq $aggr.Name){
$x += 1
$volInfo = "VOLUME: " + $vol.Name
$FlexVOLObj = add-visioobject $FlexVOLObj $volInfo
connect-visioobject $aggrObj $FlexVOLObj
}
}
# GET DATA VOL for VSERVER
$allVOLS3 = Get-NcVol -Aggregate $aggr | where {$_.Name -ne "vol0"}
foreach ($vol in $allVols3) {
if ($vol.VolumeIdAttributes.ContainingAggregateName -eq $aggr.AggregateName -and $aggr.AggrOwnershipAttributes.HomeName -eq $node.Node){
$x += 1
$volInfo = "VOLUME: " + $vol.Name
$FlexVOLObj = add-visioobject $FlexVOLObj $volInfo
connect-visioobject $aggrObj $FlexVOLObj
}
$x2 = $x
}
}
$x = 1
$y += 1
}
$x = $x2
Foreach ($vserver in $allVServers) {
if ($vserver.VserverType -eq "cluster"){
$vserverInfo = "VSERVER Name: " + $vserver
$vserverObj = add-visioobject $VServerObj $vserverInfo
$x += 1.5
#connect-visioobject $FlexVOLObj $vserverObj
}
}
# Resize to fit page
$pagObj.ResizeToFitContents()
# END Script
have fun and report any feedback
All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.
In accordance with our Code of Conduct and Community Terms of Use, DO NOT post or attach the following:
Continued non-compliance may result in NetApp Community account restrictions or termination.
Hello,
Thank you for sharing this script. I was wondering if you could help me out. I am getting the following errors. The Visio opens and it partially draws out the controller/aggregate/and two volumes but right after that it produces the errors and stops.
Please let me know what needs to be changed.
Connect-NcController : Not a Data ONTAP Cluster-mode controller
At C:\windows\System32\WindowsPowerShell\v1.0\Modules\VISIO_your_C-MODE_CONFIG_v2.ps1:72 char:21
+ Connect-NcController <<<< -Name $FASName -Credential $USERName
+ CategoryInfo : InvalidResult: (lifas01.mkllp.com:NcController) [Connect-NcController], InvalidOperation
Exception
+ FullyQualifiedErrorId : Not a Data ONTAP Cluster-mode controller,DataONTAP.C.PowerShell.SDK.ConnectNcController
Get-NcNode : Value in $global:CurrentNcController is not of type NetApp.Ontapi.Filer.C.NcController
At C:\windows\System32\WindowsPowerShell\v1.0\Modules\VISIO_your_C-MODE_CONFIG_v2.ps1:73 char:23
+ $allNODES = Get-NcNode <<<<
+ CategoryInfo : InvalidArgument: (:) [Get-NcNode], ArgumentException
+ FullyQualifiedErrorId : ControllerNotSpecified,DataONTAP.C.PowerShell.SDK.Cmdlets.System.GetNcNode
Get-NcVserver : Value in $global:CurrentNcController is not of type NetApp.Ontapi.Filer.C.NcController
At C:\windows\System32\WindowsPowerShell\v1.0\Modules\VISIO_your_C-MODE_CONFIG_v2.ps1:74 char:29
+ $allVServers = Get-NcVserver <<<<
+ CategoryInfo : InvalidArgument: (:) [Get-NcVserver], ArgumentException
+ FullyQualifiedErrorId : ControllerNotSpecified,DataONTAP.C.PowerShell.SDK.Cmdlets.Vserver.GetNcVserver
Get-NcAggr : Value in $global:CurrentNcController is not of type NetApp.Ontapi.Filer.C.NcController
At C:\windows\System32\WindowsPowerShell\v1.0\Modules\VISIO_your_C-MODE_CONFIG_v2.ps1:75 char:22
+ $allAGGR = Get-NcAggr <<<<
+ CategoryInfo : InvalidArgument: (:) [Get-NcAggr], ArgumentException
+ FullyQualifiedErrorId : ControllerNotSpecified,DataONTAP.C.PowerShell.SDK.Cmdlets.Aggr.GetNcAggr
Get-NcVol : Value in $global:CurrentNcController is not of type NetApp.Ontapi.Filer.C.NcController
At C:\windows\System32\WindowsPowerShell\v1.0\Modules\VISIO_your_C-MODE_CONFIG_v2.ps1:76 char:21
+ $allVOLS = Get-NcVol <<<<
+ CategoryInfo : InvalidArgument: (:) [Get-NcVol], ArgumentException
+ FullyQualifiedErrorId : ControllerNotSpecified,DataONTAP.C.PowerShell.SDK.Cmdlets.Volume.GetNcVol
Adding NODE:
Adding AGGREGATE:
Get-NcVol : Value in $global:CurrentNcController is not of type NetApp.Ontapi.Filer.C.NcController
At C:\windows\System32\WindowsPowerShell\v1.0\Modules\VISIO_your_C-MODE_CONFIG_v2.ps1:98 char:24
+ $allVOLS2 = Get-NcVol <<<< -Vserver $node
+ CategoryInfo : InvalidArgument: (:) [Get-NcVol], ArgumentException
+ FullyQualifiedErrorId : ControllerNotSpecified,DataONTAP.C.PowerShell.SDK.Cmdlets.Volume.GetNcVol
Adding VOLUME:
Get-NcVol : Value in $global:CurrentNcController is not of type NetApp.Ontapi.Filer.C.NcController
At C:\windows\System32\WindowsPowerShell\v1.0\Modules\VISIO_your_C-MODE_CONFIG_v2.ps1:108 char:24
+ $allVOLS3 = Get-NcVol <<<< -Aggregate $aggr | where {$_.Name -ne "vol0"}
+ CategoryInfo : InvalidArgument: (:) [Get-NcVol], ArgumentException
+ FullyQualifiedErrorId : ControllerNotSpecified,DataONTAP.C.PowerShell.SDK.Cmdlets.Volume.GetNcVol
Never mind, I did not read that you need to have Visio 2010. I will try it out with Visio 2010 and see how the results goes.
Thanks.
Hy
You need this one here: https://communities.netapp.com/docs/DOC-6411
And yes, VISIO 2010 is a must...
my script works only in C-Mode, which is differnet from the 7-Mode systems.
Exception calling "Drop" with "3" argument(s): "
An exception occurred."
At C:\NetApp\Data ONTAP PowerShell Toolkit\DataONTAP\VISIO_your_C-MODE_CONFIG_v2.ps1:29 char:5
+ $shpObj = $pagObj.Drop($mastObj, $x, $y)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : COMException
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\NetApp\Data ONTAP PowerShell Toolkit\DataONTAP\VISIO_your_C-MODE_CONFIG_v2.ps1:31 char:5
+ $shpObj.Text = $item
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At C:\NetApp\Data ONTAP PowerShell Toolkit\DataONTAP\VISIO_your_C-MODE_CONFIG_v2.ps1:19 char:2
+ $connectBegin = $shpConn.CellsU("BeginX").GlueTo($firstObj.CellsU("PinX"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Hello -
I am running the posh script against a 8.2p4 storage system running as Cdot. I am curious if the errors below are the .ps1 file issue not updated or my environment I am running this on.
Running the posh script from a win 8.1, visio 2013
Once the script is done running it will draw a big L on the visio page. I am not sure if this a script issue or a visio compatibility issue.
anyone have any ideas?
thanks!
snippet:
You cannot call a method on a null-valued expression.
At C:\NetApp\Data ONTAP PowerShell Toolkit\DataONTAP\VISIO_your_C-MODE_CONFIG_v2.ps1:21 char:2
+ $connectEnd = $shpConn.CellsU("EndX").GlueTo($secondObj.CellsU("PinX"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
hi, thanks for the script, i've been using the one made for 7-Mode it's been very helpfull since.
But i'm getting the errors below with this one, it seems like it cannot find the aggr object shape data,
and one more thing; if only you could add lun info just like in 7-mode visio script, that would be awesome.
here's the error sample, and thanks already.
---------------------------------------------------------------------
Exception getting "Item": "
Object name not found."
At C:\Users\x\Desktop\2cmode_diag.ps1:42 char:1
+ $AggrObj = $stnObj1.Masters.Item("Raid Grp Aggregate Storage")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], GetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenGetting
Exception getting "Item": "
Object name not found."
At C:\Users\x\Desktop\2cmode_diag.ps1:46 char:1
+ $FASObj = $stnObj2.Masters.Item("FAS3000")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], GetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenGetting
Exception getting "Item": "
Object name not found."
At C:\Users\x\Desktop\2cmode_diag.ps1:52 char:1
+ $FrameObject = $stnObj4.Masters.Item("Small Title min margin")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], GetValueInvocationException
+ FullyQualifiedErrorId : ExceptionWhenGetting
Adding NODE: kh2552cls-02
Exception calling "Drop" with "3" argument(s): "
An exception occurred."
At C:\Users\tolga\Desktop\2cmode_diag.ps1:25 char:11
+ $shpObj = $pagObj.Drop($mastObj, $x, $y)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : COMException
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\tolga\Desktop\2cmode_diag.ps1:27 char:11
+ $shpObj.Text = $item
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Adding NODE: node-01
Exception calling "Drop" with "3" argument(s): "
An exception occurred."
At C:\Users\x\Desktop\2cmode_diag.ps1:25 char:11
+ $shpObj = $pagObj.Drop($mastObj, $x, $y)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : COMException
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\x\Desktop\2cmode_diag.ps1:27 char:11
+ $shpObj.Text = $item
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Adding AGGREGATE: aggr0_n1
Exception calling "Drop" with "3" argument(s): "
An exception occurred."
At C:\Users\x\Desktop\2cmode_diag.ps1:25 char:11
+ $shpObj = $pagObj.Drop($mastObj, $x, $y)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : COMException
The property 'Text' cannot be found on this object. Verify that the property exists and can be set.
At C:\Users\x\Desktop\2cmode_diag.ps1:27 char:11
+ $shpObj.Text = $item
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At C:\Users\x\Desktop\2cmode_diag.ps1:16 char:5
+ $connectBegin = $shpConn.CellsU("BeginX").GlueTo($firstObj.CellsU("PinX"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\Users\x\Desktop\2cmode_diag.ps1:18 char:5
+ $connectEnd = $shpConn.CellsU("EndX").GlueTo($secondObj.CellsU("PinX"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Adding VOLUME: vol0
You cannot call a method on a null-valued expression.
At C:\Users\tx\Desktop\2cmode_diag.ps1:16 char:5
+ $connectBegin = $shpConn.CellsU("BeginX").GlueTo($firstObj.CellsU("PinX"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Tsentekin - I realize that this is an old thread, but did you download the shape files from www.visiocafe.com? If those shape files are not in the same directory as the script, I think you will get the errors you've described.
Hello Marc,
I realize that this is an old thread, but your script has been working fantastic. we Just updated to ONTAP 9.7p4, and the document creates, but will not insert the labels for all the icons. The powershell script is showing all the proper names when running, just not placing them on the icons in the Viso (2010) document as it had in the past.
Do you have any thoughts as to why this has stopped working?
Thank you for any help you provide.