<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Powershell, cleanup, delete old files, task scheduler - BugOverflow				            </title>
            <link>https://muszak.eu/community/bugoverflow/powershell-cleanup-delete-old-files-task-scheduler/</link>
            <description>muszak.eu Forum dyskusyjne</description>
            <language>pl-PL</language>
            <lastBuildDate>Thu, 17 Sep 2026 00:23:18 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Powershell, cleanup, delete old files, task scheduler</title>
                        <link>https://muszak.eu/community/bugoverflow/powershell-cleanup-delete-old-files-task-scheduler/#post-76</link>
                        <pubDate>Mon, 15 Mar 2021 10:16:06 +0000</pubDate>
                        <description><![CDATA[1. Cleanup.ps1

$Folder = &quot;C:ToBackup&quot;
$Daysback = &quot;-7&quot;

Add-Content C:logsdelete_log.txt   &quot;Cleanup started $((Get-Date).ToString())&quot;

Get-ChildItem $Folder -Recurse -Force -ea 0 |
...]]></description>
                        <content:encoded><![CDATA[<p>1. Cleanup.ps1</p>
<pre>
$Folder = "C:ToBackup"
$Daysback = "-7"

Add-Content C:logsdelete_log.txt   "Cleanup started $((Get-Date).ToString())"

Get-ChildItem $Folder -Recurse -Force -ea 0 |
? {!$_.PsIsContainer -and $_.LastWriteTime -lt (Get-Date).AddDays($Daysback)} |
ForEach-Object {
   $_ | del -Force
   $_.FullName | Out-File C:logsdelete_log.txt  -Append
}

#Delete empty folders and subfolders
Get-ChildItem $Folder -Recurse -Force -ea 0 |
? {$_.PsIsContainer -eq $True} |
? {$_.getfiles().count -eq 0} |
ForEach-Object {
    $_ | del -Force
    $_.FullName | Out-File C:logsdelete_log.txt  -Append
}
</pre>
<p>2. Task Scheulder </p>
<pre>
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -ExecutionPolicy Bypass –NoProfile –Command "&amp; {Cleanup.ps1; exit $LastExitCode}" &gt; C:logs.log
</pre>]]></content:encoded>
						                            <category domain="https://muszak.eu/community/bugoverflow/">BugOverflow</category>                        <dc:creator>mrmucha</dc:creator>
                        <guid isPermaLink="true">https://muszak.eu/community/bugoverflow/powershell-cleanup-delete-old-files-task-scheduler/#post-76</guid>
                    </item>
				                    <item>
                        <title>Powershell, cleanup, delete old files, task scheduler</title>
                        <link>https://muszak.eu/community/bugoverflow/powershell-cleanup-delete-old-files-task-scheduler/#post-75</link>
                        <pubDate>Mon, 15 Mar 2021 10:11:41 +0000</pubDate>
                        <description><![CDATA[example script]]></description>
                        <content:encoded><![CDATA[example script]]></content:encoded>
						                            <category domain="https://muszak.eu/community/bugoverflow/">BugOverflow</category>                        <dc:creator>mrmucha</dc:creator>
                        <guid isPermaLink="true">https://muszak.eu/community/bugoverflow/powershell-cleanup-delete-old-files-task-scheduler/#post-75</guid>
                    </item>
							        </channel>
        </rss>
		