Deleting Files based on Retention Period


I would like some assistance to start buidling a script to delete files from specific folders based on the retention periods mentioned in the configuration file


The script should be able to read the data from the Config file and delete all files in the folder that are equal to or greater than the time period mentioned in the tag.


Please share the code you’ve written so far.

All you need to get you going down the right direction is in the PowerShell built-in Help files…

Get parameter, examples, full and Online help for a cmdlet or function

    (Get-Command -Name Get-Content).Parameters
    Get-help -Name Get-Content -Examples
    Get-help -Name Get-Content -Full
    Get-help -Name Get-Content -Online

    (Get-Command -Name Import-Clixml).Parameters
    Get-help -Name Import-Clixml -Examples
    Get-help -Name Import-Clixml -Full
    Get-help -Name Import-Clixml -Online

    (Get-Command -Name Select-String).Parameters
    Get-help -Name Select-String -Examples
    Get-help -Name Select-String -Full
    Get-help -Name Select-String -Online

    (Get-Command -Name Get-Date).Parameters
    Get-help -Name Get-Date -Examples
    Get-help -Name Get-Date -Full
    Get-help -Name Get-Date -Online

    (Get-Command -Name Remove-Item).Parameters
    Get-help -Name Remove-Item -Examples
    Get-help -Name Remove-Item -Full
    Get-help -Name Remove-Item -Online

… and of course TechNet and MS docs sites.

PowerShell Documentaiton

PowerShell Loops