在Powershell中的visio中为连接器添加文本或标签

时间:2015-06-17 18:10:49

标签: powershell visio

我正在尝试根据通过端口号相互连接的服务器创建大量Visio图表。我已经能够创建服务器和连接器,但是,我遇到了一个问题,我无法在两个服务器形状之间的连接器上标记或添加文本。以下是最初来自Scripting Guy专栏的代码部分:

...

$networkinfo = Get-NetworkAdapterConfiguration -computer $computer
$Router = $NetworkStencil.Masters.Item("Router")
$shape4 = $page.Drop($Router,7.0,2.5)
$shape4.Text = "$($networkinfo.DefaultIPGateWay)"

$User = $NetworkStencil.Masters.Item("User")
$shape5 = $page.Drop($User,4.0,6.0)
$shape5.Text = "$($pcinfo.UserName)"

$etherNet = $NetworkStencil.Masters.Item("Ethernet")
$shape6 = $page.Drop($etherNet,2.2, 1.0)
$shape6.Text = "$(($networkinfo.IPAddress)[0])"

$connector = $ConnectorStencil.Masters.item("Dynamic Connector")
$shape1.AutoConnect($shape6, 0, $connector)
$shape2.AutoConnect($shape6, 0, $connector)
$shape3.AutoConnect($shape6, 0, $connector)
$shape4.AutoConnect($shape6, 0, $connector)
$shape5.AutoConnect($shape6, 0, $connector)

有人可以帮我弄清楚如何在服务器之间的连接器中添加文字或标签吗?

1 个答案:

答案 0 :(得分:1)

执行自动连接后,请尝试以下操作:

$arrow=$page.Shapes('Dynamic Connector') | select-object -first 1
$arrow.NameU='Unique name for this arrow'
$arrow.Text='Label for the arrow'