Created
February 12, 2021 01:53
-
-
Save mattleibow/eaa55a9088bb52d4d795e14754d78707 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory=$true)] | |
[String] $SourceDir, | |
[Parameter(Mandatory=$true)] | |
[String] $DestinationDir | |
) | |
$ErrorActionPreference = "Stop" | |
New-Item -Type Directory $DestinationDir -Force | Out-Null | |
Write-Host "Compressing all the directories(s) in '$SourceDir'..." | |
$folders = Get-ChildItem $SourceDir -Directory | |
foreach ($dir in $folders) { | |
$name = $dir.Name | |
$dest = "$DestinationDir/$name.zip" | |
Compress-Archive -Path "$dir/*" -DestinationPath $dest -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment