Help with Zip files please!

I’ve seen several posts on how to create zip files in various scenarios but I know little to nothing about PowerShell, and I’m still struggling a bit to get exactly what I need. I figured that I would just ask for help to get a fast solution without spinning my wheels, and hope you are all kind.

Please keep in mind, because of circumstances out of my control, I am using PowerShell 3.0, I can’t upgrade it, or add additional third party tools or extensions. I do have 7zip installed and at my disposal.

This is exactly what I am looking to do.

I need to zip log files. These log files are generated frequently and take up A LOT of space. They need to be held for at least 30 Days.

The log files all reside in the same directory

  1. Create a zip of each log file (.xml) individually. This file needs just standard compression and a .zip extension. The filename should be the original name + the date and time that the original file was last modified
  • Example Original file: LogFileName123.xml Last Modified on 6/7/18 at 1:25pm
  • Example of desired outcome:
  1. Zip can/should be in the same directory as the original file.

  2. Once zip is created, delete original file.

Initial script will run on a large backlog of files, then the idea would be for the script to run nightly on *.xml in the directory. (this I can handle with a windows task – no need for help there)

Any help would be greatly appreciated. I know this is probably a simple task for most, but again, I am a complete PowerShell novice, and was having trouble piecing together the many zip examples online to provide my exact scenario, particularly with my older version on PowerShell


submitted by /u/grit_fl
[link] [comments]

Leave a Reply