Advertisement
Guest User

Untitled

a guest
Oct 4th, 2021
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cmd.exe /C "C:\Program Files\IBM\InfoSphere Data Replication\Management Console\bin\chcclp.exe" -f c:\CDC_Check.txt > C:\temp\file.log
  2.  
  3. $fileContent = Get-Content -Path "C:\temp\file.log"
  4. $i=0
  5. $fileContent | %{
  6.   $i++
  7.   if($_ | Select-String -Pattern "SUBSCRIPTION       STATE" -CaseSensitive){
  8.     $headerIndex = $i
  9.   }
  10. }
  11. $headerIndex += 2
  12.  
  13. #start of data to capture
  14. $hashObj= @{}
  15. for ($x = $headerIndex; $fileContent[$x].Substring(0,1) -ne " " ;$x++){
  16.   $hashObj.Add("$($fileContent[$x].Substring(0,19).Trim(' '))","$($fileContent[$x].Substring(20,19).Trim(' '))")
  17. }    
  18.  
  19. #converts your hashtable to json object
  20. $jsonObj = $hashObj | convertto-json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement