Hallo Zusammen,
leider habe ich noch nicht viel Ahnung von Powershell und taste mich langsam vor...
ich habe folgendes Problem:ich habe alle täglichen Logfiles in ein monatliches Logfile zusammengefasst und möchte dieses monatliche Log in eine Zip-Datei "monatlicheLogs" schieben. Das soll für alle vorhandenen Ordner durchgeführt werden, deswegen
die for-Schleife.
Mein momentan "chaotischer" Code:
Set-StrictMode -Version "2.0" Clear-Host Import-Module pscx $Source="D:\bla\bla\bla" $Destination="D:\bla\bla\bla\bla" #muss existieren $Level=1 #Alle Verzeichnisse $Folders=@(Get-ChildItem -Path $Source| Where-Object {$_.name -NotLike "Test1"}| Where-Object {$_.name -NotLike "Test2"} | Where{$_.PSISContainer -Match $true}) Set-Location D:\bla\bla $jahrmonat = "{0:yyyyMM}" -f (get-date).AddMonths(-1) #sammelt die tägl. Logs in monatliche nach folgendem Muster: XXX_yyyymm for ($i=0; $i -le $Folders.Length-1; $i++) {$Files=@(Get-ChildItem -Path $Folders[$i] | SELECT Name | Format-Table -AutoSize;) $Path= $Folders[$i] $Dateiname= $Path.Name + '_' + $jahrmonat + '.log' Add-Content -Path $Source\$Path\$Dateiname -Value (Get-Content -Path $Source\$Path\u_ex*.log) $Files| Write-Zip -path $Folders[$i] -level 1 -OutputPath $Destination\$_.zip -quiet | where {$_.name -notLike "u_*"}}
Die letzte Zeile funktioniert überhaupt nicht...bekomme als Fehlermeldung:
Write-Zip : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
Wäre über jede Hilfe dankbar! Sitze jetzt schon paar Wochen dran :-/
Vielen Dank!