Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

need some help with 7 zip via powershell

$
0
0

I have this script and partial working, -rename and move  work but 7 zip didn't zip the folder supposed to be. It zipped my profile on windwos server 2008 R2:

 

$Date = (Get-Date -format "yyyy-MM-dd")
$Yr = (Get-Date -format "yyyy")
$Mo = (Get-Date -format "MM")
$Day = (Get-Date -format "dd")
$Time = (Get-Date -Format "HH-mm-ss")
$source = "\\myserver1\d$\App Backup\Backup"
$path = "\\myserver1\d$\App Backup\$Yr$Mo$Day"
$target ="\\domain\shares\Backup\App\Backup2015\"

Rename-item -path $source $path

# Zip it via 7-zip
if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {
	throw "$env:ProgramFiles\7-Zip\7z.exe needed"
}

set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"

$zipFile = "$($path).zip"
sz a -tzip "$zipfile" $dir.FullName

Move-item -path $zipFile -destination $target

Viewing all articles
Browse latest Browse all 6937

Trending Articles