Installing or updating 7-Zip using PowerShell

With the new version 18.05 released. I was met with a challenge to update allot of clients and my own computer in a way because of a security breach that was patched. So I took what I learned from other scripts I created and created this new script to install or update 7-Zip using PowerShell. Now of course the argument against this could be made for why create this because stable versions of 7-Zip do not come often. However it is a script that I share in the case that you need it. Maybe that is not now but when you do need to quickly update your own or other computers with the latest 7-Zip build here you are.

Some things to note is that the script currently uses C:\Users\[username]\AppData\7Zip as the temporary work directory to download the exe and install it from. In an example in the post I will show you how to change that.

So let’s get straight into how it works and start with the basics.


This example is the easiest one of course it uses the default options of the script. In this case the script will automatically detect your systems architecture and after that it will of course download and install the latest version of 7-Zip using the official website.

./Update-7Zip.ps1 -Verbose

The script was created to just do its job and nothing more. So there is no output to the screen by default. However you can use the example above to get debugging output of the script to see how it performs and works or hangs.

As you can see from the picture it automatically detects the architecture of the system I am running this script on. It detects in my case that the system is 64bit and of course downloads and installs that version.

You could of course change this. The architecture parameter by default is set to Detect. However if you would rather want to use a specific version you can use the Architecture switch and use either 32 or 64 as parameter options to download and install the version of 7-Zip you want. For example under here I am saying to the script that I would like to use the 32 bit version of 7-Zip instead of it otherwise automatically detecting 64 bit.

./Update-7Zip.ps1 -Architecture 32

If for any reason you would rather want to use another downloading directory to be used instead of C:\Users\[username]\AppData\Temp\7Zip then I included the parameter TemporaryDownloadFolder. It’s not the best name but it gives you the option to use another folder created or not created. The script will detect if the folder does not exist and attempt to create it.

./Update-7Zip.ps1 -TemporaryDownloadFolder "C:\Temp\"

The last example is used for if you would rather see the installing GUI appear. By default the script will silently install 7-Zip however if you would like to see the GUI and take action upon it you can use the Show switch parameter to allow you to do so.

./Update-7Zip.ps1 -Show

Keep in mind that the script is written so you can mix and match parameters and switches that are supported in the script. Also note that I created this out of speed for my deployment purposes and I am still learning PowerShell. Feedback is of course always welcome.

If you are interested you can of course download the script under here.

Download the script here

Leave a Comment