我有平面文件想用' VirtualServer'创建新的PS对象。作为名字。始终会有目的地'但并不总是' Pool' /' Node'。有时候' Pool' Node' Node'将不止一个。
VirtualServer=_1095cservicecenter.yip.com_redirect_vs
Destination=10.10.67.211%104:80
VirtualServer=aarp.yip.com_443_vs
Destination=10.10.70.63%107:443
Pool=aarp.yip.com_443_Pool
Node=trciis-na1-03-30(10.10.12.30%107)
VirtualServer=aarp.yip.com_redirect_vs
Destination=10.10.70.63%107:80
VirtualServer=abbviebenefits.yip.com_443_vs
Destination=10.10.67.87%104:443
Pool=abbviebenefits.yip.com_2t_443_Pool
Node=bob-na1-65-82(10.10.6.82%104)
Node=bob-na1-66-83(10.10.6.83%104)
Node=bob-na1-67-84(10.10.6.84%104)
Node=bob-na1-68-90(10.10.6.90%104)
Node=bob-na1-69-91(10.10.6.91%104)
Node=bob-na1-70-103(10.10.6.103%104)
Node=bob-na1-71-108(10.10.6.108%104)
Node=bob-na1-72-109(10.10.6.109%104)
Node=bob-na1-73-111(10.10.6.111%104)
必须是新对象:
VirtualServer=_1095cservicecenter.yip.com_redirect_vs
Destination=10.10.67.211%104:80
VirtualServer=aarp.yip.com_443_vs
Destination=10.10.70.63%107:443
Pool=aarp.yip.com_443_Pool
Node=trciis-na1-03-30(10.10.12.30%107)
VirtualServer=aarp.yip.com_redirect_vs
Destination=10.10.70.63%107:80
VirtualServer=abbviebenefits.yip.com_443_vs
Destination=10.10.67.87%104:443
Pool=abbviebenefits.yip.com_2t_443_Pool
Node=bob-na1-65-82(10.10.6.82%104)
Node=bob-na1-66-83(10.10.6.83%104)
Node=bob-na1-67-84(10.10.6.84%104)
Node=bob-na1-68-90(10.10.6.90%104)
Node=bob-na1-69-91(10.10.6.91%104)
Node=bob-na1-70-103(10.10.6.103%104)
Node=bob-na1-71-108(10.10.6.108%104)
Node=bob-na1-72-109(10.10.6.109%104)
Node=bob-na1-73-111(10.10.6.111%104)
如何创建,这不起作用:
$LoadBalancer = "(?<VirtualServer=>\S*)",
"(?<Destination=>\S*)",
"(?<Pool=>\S*)",
"(?<Node=>\S*)" -join "\s+"
答案 0 :(得分:-1)
首先需要读取平面文件并进行适当的解析并使用以下两个命令的组合:
$object = New-Object psobject
和
Add-Member -InputObject $object -MemberType NoteProperty -Name HeaderName -value "Value"