Move files to a zip file
############################################################
#
# NAME : Move-ZIP
#
# AUTHOR : Wessel van Sandwijk
#
# Website : http://www.useful-it.nl
#
# COMMENT : Move ZipFile
#
# VERSION HISTORY :
# 1.0 07-MRT-2013 - Initial Version
#
############################################################
dir c:\demo\files\*.* -Recurse | Move-Zip c:\demo\myzip.zip
############################################################
#
# FUNCTIONS
#
############################################################
function Move-Zip
{
param([string]$zipfilename)
if(-not (test-path($zipfilename)))
{
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipfilename).IsReadOnly = $false
}
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
foreach($file in $input)
{
$zipPackage.MoveHere($file.FullName)
Start-sleep -milliseconds 500
}
}
About The Author
I am a DevOps Engineer from the Netherlands.
My Skills are mainly PowerShell, Ansible, Choco, Automation, Active Directory, VMWare, Hyper-V and Security.
Post navigation
More Stories
Running PowerShell Hyper-V and VMWare Modules
Extend the Evaluation Period on Windows Server
Now using Ansible, Chocolatey, Powershell