How to unzip in Powershell

07 February,2019 by Jack Vamvas

Question: I have a zip file , which I normally  win-zip or unzip . I'd like to unzip an archive file as part of a Powershell script

 

Answer: You can use the Powershell cmdlet - Expand-Archive . I've also included some added bits around the  ps cmdlet Expand-Archive , which will assist in managing access  & file clean up .

 

# Unblock if there's a block – common problem

Unblock-File test.zip   -ErrorAction SilentlyContinue

     

#the actual expand process

Expand-Archive -Path test.zip -DestinationPath e:\exsample\sql_server\modules -Force

 

#to remove your zip file

Remove-Item -Path test.zip

 

Read more on Powershell scripts

Powershell Script Library for DBA (SQL Server DBA)

Expand your Powershell mind – Three key cmdlets

 


Author: Jack Vamvas (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to unzip in Powershell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer