Hi,
I have a code like below. In the source folder I have folders, sub folders and files.
I need to zip the entire source folder and place the zip file in to some location, while zipping I need to skip one specific folder. But when am trying with below its not working. I need to have only one zip file without specific folder in that.
Could anyone please suggest a way on this.
$sourcePath = ‘D:\Dinesh\lob1\lata’
$destination = ‘E:\Kumar\lob1\lata\emerged-data-1.zip’
$excludefolder = ‘processarea’
If(Test-Path $destination)
{
Remove-Item -Path $destination -Force -ErrorAction Stop
}
$items = Get-ChildItem -Path $sourcePath -Recurse -Exclude $excludefolder
Add-Type -AssemblyName “system.io.compression.filesystem”
$items | Foreach{
[io.compression.zipfile]::CreateFromDirectory($_.Fullname,$destination)
}
Thanks,
Dinesh