PowerShell : Zip a Folder and Delete the Old One
Hello Wiki,
Here is a Script which I used It today in my environment in order to Identify a day ago Folder named in Date format and push to ZIP It and then delete the folder Itself.
$Time = (get-date).AddDays(-1).ToString("yyyMMdd")
$FName = Get-ChildItem c:\Source -filter "$Time"
$source = "$FName"
$destination = "D:\Dest\$Time.zip"
If(Test-path $destination) {Remove-item $destination}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($Source, $destination)
Remove-Item -Path C:\Source\$Fname
Hope It will help to whom search for these kind of Scripts.