I am trying to delete a folder with subfolders/files.
Remove-Item -Force -Recurse -Path $directoryPath
I am getting the error Cannot remo
Cannot remo
this worked for me where i deleted files and folders older then i year recursively including folders.
Get-ChildItem -Directory -Path X:\AutomateCache | where-Object {$_.Lastwritetime -ile (get-date).AddMonths(-12) } | Remove-Item -Force -Recurse -Verbose