mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 16:33:20 +01:00
21 lines
609 B
PowerShell
Executable File
21 lines
609 B
PowerShell
Executable File
#!/usr/bin/pwsh
|
|
<#
|
|
.SYNTAX zip-dir.ps1 [<directory>]
|
|
.DESCRIPTION creates a zip archive of the given directory
|
|
.LINK https://github.com/fleschutz/PowerShell
|
|
.NOTES Author: Markus Fleschutz / License: CC0
|
|
#>
|
|
|
|
param($Directory = "")
|
|
if ($Directory -eq "" ) { $Directory = read-host "Enter the path to the directory to zip" }
|
|
|
|
try {
|
|
compress-archive -path $Directory -destinationPath $Directory.zip
|
|
|
|
write-host -foregroundColor green "Done - created zip archive $($Directory).zip"
|
|
exit 0
|
|
} catch {
|
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
exit 1
|
|
}
|