💻 Software
PowerShell zip file synchronously
Fresh5 days ago
Mar 15, 20267690 viewsConfidence Score0%
0%
Problem
In a PowerShell script, I want to zip a folder before deleting the folder. I run the following (I don't remember where I found the snippet): This snippet actually compress the folder, but in an asynchronous way. In fact, the CopyHere method of the Shell.Application objects starts the compression an…
Error Output
function Compress-ToZip
{
param([string]$zipfilename)
if(-not (test-path($zipfilename)))
{
set-content $zipfilename ("PK" + [cha…Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: PowerShell zip file synchronously
Low Risk
I finally found a clean way, playing with the properties of the com objects. Especially, the following snippet can test if the file is present in the zip file : The full script is the following :
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix