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

Create a zip archive then move a file to it

$
0
0

I've just started using Powershell and I want to create z zip archive then move a file to it

Creating the zip works fine but I am having no joy moving the file to it 

I'm using:

$zipfilename = 'c:\cwRsync\backup.zip'
$file = 'c:\cwRsync\backup.log'
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipfilename).IsReadOnly = $false
$zipfile = (New-Object -ComObject shell.application).NameSpace($zipfilename)
$zipfile.MoveHere($file)

No errors but it doesn't work :(
Any help would be much appreciated
I did manage to use Copy-ToZip to add a file and I could use that then delete the file but I would really like to know what is wrong with my script
Any help would be much appreciated

 

 

 


Viewing all articles
Browse latest Browse all 8583

Latest Images

Trending Articles



Latest Images