I have written the following script using a post on this forum. The script deletes the files which are older than 15 days:
cls$servers = Get-Content server.txt$limit =(Get-Date).AddDays(-15)$path ="E:\CheckDBOutput"
ForEach ($line in$servers){
Invoke-Command -cn line -ScriptBlock { Get-ChildItem -Path $path -Recurse -Force | Where-Object {!$_.PSIsContainer -and$_.CreationTime -lt $limit }| Remove-Item -Force}}The script is executing fine without errors, but no files are getting deleted.
Kindly tell me what modification should I do for making this script working. Thanks in advance.