Windows includes the ability to unzip archives and even exposes this functionality programmatically via COM. Here is how to do it.
How to Extract ZIP Files Using PowerShell
We have seen this question asked numerous times on Stack Overflow and forums alike but most of the time people recommend using the PowerShell Community Extensions or a legacy command line application. Truth be told, its not actually all that hard to do in PowerShell.
$shell = new-object -com shell.application
$zip = $shell.NameSpace(āC:\howtogeeksite.zipā)
foreach($item in $zip.items())
{
$shell.Namespace(āC:\temp\howtogeekā).copyhere($item)
}
Hardcoding values isn’t really ideal so lets make it into a quick function.
function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
Then we can simply use the function like this:
Expand-ZIPFile āFile āC:\howtogeeksite.zipā āDestination āC:\temp\howtogeekā
Remember to add thisĀ to your Windows PowerShell profile, so that you donāt need third-party libraries for functionality that is already included out of the box.
- › Here’s How Netflix Will Stop You From Sharing Passwords
- › Samsung’s Galaxy S23 Has a Sleeker Design, Big Upgrades
- › Here’s How to Use Gmail’s New Package Tracking
- › Samsung’s Galaxy Book 3 Laptops Have 120Hz AMOLED Displays
- › The Samsung Galaxy S23 Ultra Has a Wild 200 MP Camera
- › What Is the Snapdragon 8 Gen 2 for Galaxy?