I am looking for help in creating a PS script to parse a file with vertical grouped text.
I have a file that contains the output of a query of catalog information. My goal is to take this vertical information and create a single row of information that can be inserted into a SQL database. The first thing I need to figure out is how to successfully parse the file to create the rows to insert. If I can figure out how to change this from vertical to row data, I think I can figure out how to write that row data into SQL. I have seen many techniques as I searched the Internet, but none fit the pattern of my input file which doesn't have a clear delimiter. The output file will have a consistent number of vertical lines to convert to a row.
Here is the output I am looking for (5 rows of data. I'm assuming I can then parse a comma delimited file or PS array to build a SQL insert statement, but please correct me if that is an incorrect assumption:
E9-TRACEIT,TRACEIT,Lgcy,Srv,Full,No,Active,02/15/2014 02:00:37,90.31 MB,Yes,No,None,No,20140215020037\00002C26,5,DEFAULT
E9-MSOC,MgrValue,Lgcy,Srv,Full,No,Active,02/15/2014 02:00:35,1.46 GB,Yes,No,None,No,20140215020035\00000B4F,5,DEFAULT
E9-MSOC,MgrValueDW,Lgcy,Srv,Full,No,Active,02/15/2014 02:05:19,7.09 GB,Yes,No,None,No,20140215020519\00000B4F,5,DEFAULT
E9-MSOC,SrvrLane,Lgcy,Srv,Full,No,Active,02/15/2014 02:05:58,12.70 MB,Yes,No,None,No,20140215020558\00000B4C,5,DEFAULT
E9-MSOC,SrvrLaneTempDB,Lgcy,Srv,Full,No,Active,02/15/2014 02:05:59,928.00 KB,Yes,No,None,No,20140215020559\00000B4C,5,DEFAULT
Here is the file to be parsed
Backup Object Information
-------------------------
SQL Server Name ........................ E9-TRACEIT
SQL Database Name ........................ TRACEIT
Backup Method ........................ Lgcy
Backup Location ........................ Srv
Backup Object Type ....................... Full
Backup on Secondary Replica .............. No
Backup Object State ...................... Active
Backup Creation Date / Time .............. 02/15/2014 02:00:37
Backup Size .............................. 90.31 MB
SQL Compressed ........................... Yes
Backup Compressed ........................ No
Backup Encryption Type ................... None
Backup Client-deduplicated ............... No
Database Object Name ..................... 20140215020037\00002C26
Number of stripes in backup object ....... 5
Assigned Management Class ............... DEFAULT
Backup Object Information
-------------------------
SQL Server Name ........................ E9-MSOC
SQL Database Name ........................ MgrValue
Backup Method ........................ Lgcy
Backup Location ........................ Srv
Backup Object Type ....................... Full
Backup on Secondary Replica .............. No
Backup Object State ...................... Active
Backup Creation Date / Time .............. 02/15/2014 02:00:35
Backup Size .............................. 1.46 GB
SQL Compressed ........................... Yes
Backup Compressed ........................ No
Backup Encryption Type ................... None
Backup Client-deduplicated ............... No
Database Object Name ..................... 20140215020035\00000B4F
Number of stripes in backup object ....... 5
Assigned Management Class ............... DEFAULT
Backup Object Information
-------------------------
SQL Server Name ........................ E9-MSOC
SQL Database Name ........................ MgrValueDW
Backup Method ........................ Lgcy
Backup Location ........................ Srv
Backup Object Type ....................... Full
Backup on Secondary Replica .............. No
Backup Object State ...................... Active
Backup Creation Date / Time .............. 02/15/2014 02:05:19
Backup Size .............................. 7.09 GB
SQL Compressed ........................... Yes
Backup Compressed ........................ No
Backup Encryption Type ................... None
Backup Client-deduplicated ............... No
Database Object Name ..................... 20140215020519\00000B4F
Number of stripes in backup object ....... 5
Assigned Management Class ............... DEFAULT
Backup Object Information
-------------------------
SQL Server Name ........................ E9-MSOC
SQL Database Name ........................ SrvrLane
Backup Method ........................ Lgcy
Backup Location ........................ Srv
Backup Object Type ....................... Full
Backup on Secondary Replica .............. No
Backup Object State ...................... Active
Backup Creation Date / Time .............. 02/15/2014 02:05:58
Backup Size .............................. 12.70 MB
SQL Compressed ........................... Yes
Backup Compressed ........................ No
Backup Encryption Type ................... None
Backup Client-deduplicated ............... No
Database Object Name ..................... 20140215020558\00000B4C
Number of stripes in backup object ....... 5
Assigned Management Class ............... DEFAULT
Backup Object Information
-------------------------
SQL Server Name ........................ E9-MSOC
SQL Database Name ........................ SrvrLaneTempDB
Backup Method ........................ Lgcy
Backup Location ........................ Srv
Backup Object Type ....................... Full
Backup on Secondary Replica .............. No
Backup Object State ...................... Active
Backup Creation Date / Time .............. 02/15/2014 02:05:59
Backup Size .............................. 928.00 KB
SQL Compressed ........................... Yes
Backup Compressed ........................ No
Backup Encryption Type ................... None
Backup Client-deduplicated ............... No
Database Object Name ..................... 20140215020559\00000B4C
Number of stripes in backup object ....... 5
Assigned Management Class ............... DEFAULT
The operation completed successfully. (rc = 0)
c:\Program Files\Tivoli\TSM\TDPSql>