I have below script to delete the old files:
Get-ChildItem -Path "D:\VeeamSilo1\TEST Folder"-Recurse -Exclude *.vbm |
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-0)}| #Finding the last 28 days of data
ForEach-Object {
$_ | del -Force
$_.FullName, $_.LastWriteTime | Out-File C:\temp\report_3.txt -Append
}
But I am getting the pop-up window with below message:
"The item at Microsoft.PowerShell.Core\FileSystem::D:\VeeamSilo1\TEST Folder|New folder has children and the Recurse parameter was not specified. If you continue, all children will be removed with the item. Are you sure you want to continue?"
[Yes] [Yes to All] [No] [No to All] [Suspend]
How to say [No to All] automatically with sript. I tried "Try catch" method but it is not working.
https://stackoverflow.com/questions/202 ... nfirmation
Regards,
Kiran