Hi all,
i'm new to PS. I have to write a script which clean up log files. All files from the same date shoud be ziped in one file. Files of the actual date shoud not be ziped. My filter works, but i don't know how to use it for genearation of zip files.
My code snippet:
Function GetOldFiles
{
$TargetFolder = "C:\MyTestData"
if (Test-Path $TargetFolder)
{
$Now = Get-Date -f 'yyyy-MM-dd'
$MyArray = Get-ChildItem $TargetFolder |
Where-Object {!$_.psIsContainer -and $_.name -like "*.log" -and $_.name -ne "Boot.log" -and $_.LastWriteTime -lt $Now} |
Group-Object {'{0:yyyy"-"MM"-"dd}' -f $_.LastWriteTime} | Sort-Object Name
#Display the Array to check the filter
$MyArray
}
Else
{Write-Host "The Folder $TargetFolder Does Not Exist!"}
}
GetOldFiles
---------------------
Any clues to my problem are welcome. Many thanks for your help.
;) Carlos Di Vega