How can I create a PowerShell script to get all files of type .BAK and add them to a ZIP file (can I have my PowerShell script take a parameter when called to control the name o
If you're using PowerShell v5 then you can use the Compress-Archive
function instead of using 7zip:
$filePath = "C:\SQLBackups"
$ZipName = "v4.14.4_backups.zip"
$BakFiles = Get-ChildItem -Recurse -Path $filePath -Include *.bak
$BakFiles | Compress-Archive -DestinationPath "$filePath\$ZipName"
$BakFiles | Remove-Item -Force