Forum Discussion

VictorLanso's avatar
VictorLanso
Copper Contributor
Sep 01, 2022
Solved

PowerShell Compress-Archive

I have a monthly backup folder which contains daily backup from 1st day of the month to the last day of the month. How can i use PowerShell to zip each backup into the same folder or another folder all at once. I want the backup zip on a daily basis. 

Parent folder is C:\January2022>

Childitems C:\Jan-1 through Jan-30

 

 PS C:\Users\IT\TestFolder1> compress-Archive *.* -destinationpath C:\testfolder3\Test.zip 

Above zip all contents at once into test.zip  but i want separate childitem zip into destination.

 

 

  • Here you go: https://github.com/Raindrops-dev/RAIN-TechCommunityContributions/blob/main/Start-SubfolderCompression.ps1

    Read the .Example code at the top for the parameters to use when calling the script.

6 Replies

  • raindropsdev's avatar
    raindropsdev
    Iron Contributor
    Your backups are in subfolders? Or all the backup in one folder?
    Is your goal to compress each subfolder to a different .zip file?
    • VictorLanso's avatar
      VictorLanso
      Copper Contributor
      All backups are in subfolders. And my goal is to compress each subfolder to a different .zip file. with just a command or script. With that I should be able to manage many backups at once.

      Thanks.
      • raindropsdev's avatar
        raindropsdev
        Iron Contributor
        Here you go: https://github.com/Raindrops-dev/RAIN-TechCommunityContributions/blob/main/Start-SubfolderCompression.ps1

        Read the .Example code at the top for the parameters to use when calling the script.

Resources