========= Zip.ps1 ======================================= 
 Name: Zip.ps1 
 Purpose: Demonstrate how to create a compressed .ZIP file and add files to it using PowerShell. Demonstrate multiple methods to extract files from a .zip 
 Author: Dan Stolts - dstolts$microsoft.com - http://ITProGuru.com 
 Syntax/Execution: Copy portion of script you want to use and paste into PowerShell (or ISE)  
 Description: Delete, Create, and add files to a zip file and extract files 
 Disclaimer: Use at your own Risk!  See details at http://ITProGuru.com/privacy  
         * Must Run PowerShell (or ISE)  
        * UAC may get in the way depending on your settings (See: http://ITProGuru.com/PS-UAC) 
# Create Zip Archive from files/folder 
Del C:\_Data\SkyDrive.MS\TR21\*.zip                                                  # Delete the archive files 
Compress-Archive "C:\_Data\SkyDrive.MS\TR21\website" "C:\_Data\SkyDrive.MS\TR21\website.zip" -Force    # Create .zip file from folder 
Dir C:\_Data\SkyDrive.MS\TR21\*.zip                                                  # Show the .Zip file  
get-help Compress-Archive                                                            # Show Help 
# Extract Files from Zip Archive 
Dir C:\_Data\SkyDrive.MS\TR21\W* 
Expand-Archive "C:\_Data\SkyDrive.MS\TR21\website.zip" "C:\_Data\SkyDrive.MS\TR21\Website.Expand" -Force 
dir "C:\_Data\SkyDrive.MS\TR21\Website.expand" -Recurse 
Del "C:\_Data\SkyDrive.MS\TR21\Website.expand" -Recurse -force 
dir "C:\_Data\SkyDrive.MS\TR21\Website.expand" -Recurse 
# or Extract the long way... 
Dir C:\_Data\SkyDrive.MS\TR21\a* 
$shell = new-object -com shell.application 
$Path = “C:\_Data\SkyDrive.MS\TR21\AzureManagement.zip” 
$zip = $shell.NameSpace($Path)  #file must exist 
foreach($item in $zip.items()) { 
 $shell.Namespace(“C:\_Data\SkyDrive.MS\TR21\”).copyhere($item# Folder must exist 
 Dir C:\_Data\SkyDrive.MS\TR21\a* 
 Dir C:\_Data\SkyDrive.MS\TR21\AzureManagement\ 
# Del "C:\_Data\SkyDrive.MS\TR21\AzureManagement" -Recurse 
# video of Script https://channel9.msdn.com/Series/GuruPowerShell 
# More scripts from Dan Stolts "ITProGuru" at http://ITProGuru.com/Scripts



Demonstrate how to create a compressed .ZIP file and add files to it using PowerShell. Demonstrate multiple methods to extract files from a .zip. Delete, Create, and add files to a zip file and extract files from a .ZIP


Brought to you by ITProGuru Dan Stolts.

Blog: http://ITProGuru.com

Script Home: http://ITProGuru.com/Scripts

Accompanying Video on Channel 9 at https://channel9.msdn.com/Series/GuruPowerShell