I'm very new to Powershell. Only have been using it for about 2 weeks.
I have a file that is structured like this:
Service name: WSDL Service ID: 14234321885 Service resolution path: /gman/wsdlUpdte Serivce endpoints: -------------------------------------------------------------------------------- Service name: DataService Service ID: 419434324305 Service resolution path: /widgetDate_serv/WidgetDateServ Serivce endpoints: http://servername.company.com:1012/widgetDate_serv/WidgetDateServ -------------------------------------------------------------------------------- Service name: SearchService Service ID: 393234543546 Service resolution path: /ProxyServices/SearchService Serivce endpoints: http://servername.company.com:13010/Services/SearchService_5_0 http://servername2.company.com:13010/Services/SearchService_5_0 -------------------------------------------------------------------------------- Service name: Worker Service ID: 14187898547 Service resolution path: /ProxyServices/Worker Serivce endpoints: http://servername.company.com:131009/Services/Worker/v9 --------------------------------------------------------------------------------
I'd like to parse the file and have Service name, Service ID, Service Resolution Path and Service Endpoints (which sometimes contain multiple or no values) in individual columms (CSV).
Beyond using Get-Content and looping through the file, I have no idea even where to start.
Any help will be appreciated. Thanks
Give this a try:
Create new object for each item
Here is a general way parsing files with records and records of records (and so on), it use the powerfull PowerShell
switch
instruction with regular expressions and the begin(), Process(), end() function template.Load it, debug it, correct it ...
Try this:
Basically it boils down to:
Hope this points you in the right direction.
Note: Code is untested.
with PowerShell 5 you can use the fabulous command 'convertfrom-string'