by key88 at 2013-02-19 09:00:13
I’m not sure if this is the right place, but I found you all through the FB powershell page.by poshoholic at 2013-02-19 09:28:10
I’m trying to use powershell to build a visio diagram of my network. What I need help with is populating the details of the server shape. Below is a snipet:
$Stencil = $Visio.Documents.Add("periph_m.vss") # Add networking stencils
$item = $Stencil.Masters.Item("Server")
$item.Name = "Server1"
$shape = $page.Drop($item, 1.0, 10.6)
$shape.Text = "Server1"
In the shape data I’d like to populate the IP address and other items but I can’t figure out how to do this.
I’m using visio 2010 and powershell ver 3 and I’ve attached a screen shot of what I’m trying to populate.
TIA
I believe you need to use something like this:by ArtB0514 at 2013-02-19 09:54:59
Shape.CellsU("SomePropertyIdentifier").ResultIU = ‘SomeValue’
I’m not set up to test this at the moment, but essentially I think you need to (a) find the property identifier to get the property, then (b) figure out what property of that cell is used to set the value to the IP address you want.
It’sby key88 at 2013-02-19 10:49:38$Shape.CellsU("Prop.Identifier").FormulaU
"Identifier" is the property name minus any space characters. So the Identifier for "IP Address" is "IPAddress". Note that by default, all these values are read-only. I haven’t figured out how to set them to read-write.
[quote="poshoholic"]I believe you need to use something like this:by key88 at 2013-02-21 16:16:49
Shape.CellsU("SomePropertyIdentifier").ResultIU = ‘SomeValue’
I’m not set up to test this at the moment, but essentially I think you need to (a) find the property identifier to get the property, then (b) figure out what property of that cell is used to set the value to the IP address you want.[/quote]
This got me in the ballpark, the property turns out to be a double, so trying to put a dotted decimal format IP address fails, I can put in the IP address without the dots, but that is not really acceptable. I also tested with the Operating System property and found that it is a double as well and does not accept strings.
Well not a perfect solution, found a module VisioPS on codeplex. I found it here: http://visioautomation.codeplex.com/
Below is a sample that let’s me get started.
Import-Module VisioPS
$app = New-VisioApplication
$doc = New-VisioDocument
$Stencil_PC = Open-VisioStencil "Computers and Monitors.vss"
$Stencil_Net = Open-VisioStencil "periph_m.vss"
$pc_master = Get-VisioMaster -Master "PC" -Stencil $Stencil_PC
$pc_Server = Get-VisioMaster -Master "Server" -Stencil $Stencil_Net
$points = (0.0,0.0,0.0 )
$server = New-Visioshape $pc_Server $points
$Props = Set-VisioCustomProperty -Name IPAddress -Value "123.123.123.123"
Set-VisioText "Server1"
$points = (1.0,1.0,1.0 )
$server = New-Visioshape $pc_Server $points
$Props = Set-VisioCustomProperty -Name IPAddress -Value "123.123.123.321"
Set-VisioText "Server2"
$doc.Close()