Code:
function New-Zip
{
param([string]$zipfilename)
set-content $zipfilename (\"PK\" + [char]5 + [char]6 + (\"$([char]0)\" * 18))
(dir $zipfilename).IsReadOnly = $FALSE
}
new-zip c:\Powershell\TESTSCRIPTS\Archiv\archiv.zip
function Add-Zip
{
param([string]$zipfilename)
if(-not (test-path($zipfilename)))
{
set-content $zipfilename (\"PK\" + [char]5 + [char]6 + (\"$([char]0)\" * 18))
(dir $zipfilename).IsReadOnly = $FALSE
}
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
foreach($file in $Input)
{
$zipPackage.CopyHere($file.FullName)
Start-sleep -milliseconds 500
}
}
dir c:\Powershell\TESTSCRIPTS\*.* -Recurse | add-Zip c:\Powershell\TESTSCRIPTS\Archiv\archiv.zip
$now = get-date
dir C:\POWERSHELL\Testscripts\*.* -recurse | where-object {($now - $_.LastWriteTime).Days -gt 10} | remove-item falls es jemanden interessiert...habs letztendlich selber hinbekommen, vllt. kanns ja mal irgendwer brauchen.