I am trying to zip all folders I find in my folder called services
.
I use Get-Childitem
to find these folders and I want to add the function after the pipeline, but it doesn't work out the way I want.
The zip file should have the same name as the folder itself, so I tried to give the name with "$.FullName" and destinationpath is the folder "C:\com\$.Name"
Here is my script :
Get-ChildItem "C:\com\services" | % $_.FullName
$folder = "C:\com\services"
$destinationFilePath = "C:\com"
function create-7zip([String] $folder, [String] $destinationFilePath)
{
[string]$pathToZipExe = "C:\Program Files (x86)\7-Zip\7zG.exe";
[Array]$arguments = "a", "-tzip", "$destinationFilePath", "$folder";
& $pathToZipExe $arguments;
}