Backing Up All Scripts to ZIP

by Oct 1, 2018

PowerShell 5 finally includes support for ZIP files, so if you want to backup all of your PowerShell scripts into one ZIP file, here is a one-liner:

Get-ChildItem -Path $Home -Filter *.ps1 -Recurse -ErrorAction SilentlyContinue |
  Compress-Archive -DestinationPath "$home\desktop\backupAllScripts.zip" -CompressionLevel Optimal

Note that on Windows 10, all files are passed through your AV engine before they are written to ZIP. If your AV engine detects a suspicious script, chances are you get an exception and no ZIP file.

Twitter This Tip! ReTweet this Tip!