0

I have flat file would like to create new PS objects with the 'VirtualServer' as the Name. There will always be 'Destination' but not always 'Pool'/'Node'. Sometimes 'Pool'/'Node' will be more than one.

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)

Must be new objects:

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)

How to create, this not working:

$LoadBalancer = "(?<VirtualServer=>\S*)",
   "(?<Destination=>\S*)",
   "(?<Pool=>\S*)",
   "(?<Node=>\S*)" -join "\s+"
3
  • 2
    How is it not working? Do you get errors? Do you get the wrong data? Do you get no data? How are you loading the file? How are you trying to access the data? All you have shown us is an array that you are joining into a string. What do you then do with that string? Do you use it in a regular expression? Do you print it out and mail it to Santa Claus so he knows what presents to bring you? Commented Apr 16, 2018 at 12:07
  • Thank you Santa Claus. If I list "VirtualServer" then I want it give me "Destination" and "Pool" and "Node" with that VirtualServer. So one PS object with this details. Commented Apr 16, 2018 at 13:06
  • Please edit your question to add this detail and show actual code. Please show an MCV Commented Apr 16, 2018 at 13:30

1 Answer 1

-1

You first need to read in the flat file and parse that appropriately and use a combination of the two following commands:

$object = New-Object psobject

and

Add-Member -InputObject $object -MemberType NoteProperty -Name HeaderName -value "Value"
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.