Reading .gz files.
Does anyone know if there is a way to read .gz files with Powershell?  I need to look for specific text in a large group of .gz log files.  Thanks for any ideas or help.
July 8th, 2010 9:35pm

Well, how many hoops are you willing go through?  I'm not aware of any .gz unzipper for Windows other than Cygwin: http://www.cygwin.org/cygwin/ .

So you may have to have PowerShell cally Cygwin to unzip the files...

Free Windows Admin Tool Kit Click here and download it now
July 8th, 2010 10:07pm

May want to check this out for ideas: http://wannemacher.us/?p=225

He's using the .NET GZipStream class: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx

July 8th, 2010 10:18pm

You can also look at the PowerShell Community extensions

http://www.google.ch/url?sa=t&source=web&cd=1&ved=0CBoQFjAA&url=http%3A%2F%2Fpowershellcx.codeplex.com%2F&ei=pOc2TJn4CYKgOP3Q4egF&usg=AFQjCNG5VhOFRp-BC_djPPsP7gyMTmD3xQ

This Module contains Cmdlets like :

read-Arichive and Write-Gzip (write-Tar etc.)

 

Greetings MOW

Free Windows Admin Tool Kit Click here and download it now
July 9th, 2010 12:12pm

I wrote a function for this exact purpose and figured I'd share it here:

http://gallery.technet.microsoft.com/scriptcenter/ConvertFrom-GZip-edcbf6a9

It will read the contents of the GZip file and write it into the shell as one System.String object per line of text.  I combine it with a filter to gather log data for my network team.

January 11th, 2014 1:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics