Forum Discussion
FlynnThorne
Apr 28, 2025Iron Contributor
How to password protect a zip file in Windows 11?
I know how to create a zip archive in Windows 11 but I don't know how to add password to zip file as the files are quite sensitive and confidential. What's the easiest way to password protect a zip ...
NathanRodriguez
Apr 28, 2025Iron Contributor
Below is a powershell script you can use to password protect a zip in Windows 11 or Windows 10.
# load the compression function
Add-Type -AssemblyName System.IO.Compression.FileSystem
# define path and password
$sourcePath = "C:\path\to\your\file.txt"
$zipPath = "C:\output\encrypted.zip"
$password = "YourPassword123"
#create new zip file
$tempFolder = [System.IO.Path]::GetTempPath() + [Guid]::NewGuid().ToString()
New-Item -ItemType Directory -Path $tempFolder -Force
# copy new zip file to a tmp folder
Copy-Item $sourcePath -Destination $tempFolder
# add password to zip file
[System.IO.Compression.ZipFile]::CreateFromDirectory($tempFolder, $zipPath)
# delete tmp files
Remove-Item $tempFolder -Recurse -Force
Summary
- Simple requirements → Use Windows built-in tools (method 1).
- Strong encryption needs → use 7-Zip (method 2).
- Automated scripts → Create ZIP with PowerShell and encrypt it manually (Method 3 combined with Method 1/2).