Can I use PDQ Deploy to delete folders and files of a certain age?

Comments

2 comments

  • Callan Johnstone

    Hi Mike, Maybe the following can assist or point you in the right direction The "@(temp)" path is a custom variable I set in PDQ deploy to target C:\Temp on the target machine

    #Define Path
    $Path = “@(temp)”
    
    #Get Current Date
    $CurrentDate = Get-Date
    
    #Define age '50 days old'
    $Daysback = "-50”
    
    #Current date minus specified age
    $DatetoDelete = $CurrentDate.AddDays($Daysback)
    $FilesToDelete = Get-ChildItem $Path -Recurse -File | Where-Object { $_.LastWriteTime -lt $DatetoDelete } | Remove-Item -Verbose
    
    0
    Comment actions Permalink
  • Michael Faucher

    Many thanks! I'll give this a go... Best Mike

    0
    Comment actions Permalink

Please sign in to leave a comment.