I am trying to create powershell script function to zip a folder excluding some folders and files here is my code, which create zip file including all files and folder
# Zip creator method
function create-zip([String] $aDirectory, [String] $aZipfile){
[string]$pathToZipExe = "C:\Program Files\7-zip\7z.exe";
[Array]$arguments = "a", "-tzip", "$aZipfile", "$aDirectory";
& $pathToZipExe $arguments;
}
but i want to exclude *.tmp files and bin and obj folder
I found Get-ChildItem "C:\path\to\folder to zip" -Recurse -Exclude *.txt, *.pdf | %{7za.exe a -mx3 "C:\path\to\newZip.zip" $_.FullName}
is working fine as powershell command but how to use it in function of script file
Plz suggest...