powershell 文件夹清理

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 文件夹清理相关的知识,希望对你有一定的参考价值。

Scheduled to run daily is the task to delete any TIF files older than 10 days.

Script example: (all scripts run with the dwpkof service acct).

$kidd3 = "e:\Kofax\KCXMLImport\Input\kidd3"
get-childitem $kidd3 |where-object {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays(-10)}| foreach-object {remove-item $kidd3\$_ -recurse -force -confirm:$false}

$kidd4 = "e:\Kofax\KCXMLImport\Input\kidd4"
get-childitem $kidd4 |where-object {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays(-10)}| foreach-object {remove-item $kidd4\$_ -recurse -force -confirm:$false}

$kidd5 = "e:\Kofax\KCXMLImport\Input\kidd5"
get-childitem $kidd5 |where-object {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays(-10)}| foreach-object {remove-item $kidd5\$_ -recurse -force -confirm:$false}

$imagestore = "e:\ibml\imagestore"
get-childitem $imagestore | where-object {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays(-10)}| foreach-object {remove-item $imagestore\$_ -recurse -force -confirm:$false}

Scheduled to run on a weekly basis is the task to delete log files older than 3 months, or 6 months in the case of kofax\logs.

Example:

$path4 = "E:\Kofax\KCXMLImport\Error"
get-childitem $path4 |where-object {$_.psiscontainer -and $_.lastwritetime -le (get-date).addmonths(-3)}| foreach-object {remove-item $path4\$_ -recurse -force -confirm:$false}

$path1 = "E:\Kofax\KCXMLImport\Input\XML_Backups"
get-childitem $path1 |where-object {$_.psiscontainer -and $_.lastwritetime -le (get-date).addmonths(-3)}| foreach-object {remove-item $path1\$_ -recurse -force -confirm:$false}

$path2 = "E:\IBML\ScanLogs"
get-childitem $path2 |where-object {$_.lastwritetime -le (get-date).addmonths(-3)}| foreach-object {remove-item $path2\$_ -recurse -force -confirm:$false}

Folders affected are:

\kofax\logs\                                                                        6 months (logs)
\kofax\images                                                                  10 days (tifs)
\kofax\kcxmlimport\input\scannerid                     10 days (tifs)
\kofax\kcxmlimport\input\xml_backups              3 months (xml’s)
\kofax\kcxmlimport\error                                           3 months (xml’s)
\kofax\imagestore\                                                        10 days (tifs)
\kofax\ibml-kodak\scannerlogs                                3 months (logs)

Running on servers KIDLIC0001, KIDKDS0001, TELLIC0001 and TELKDS0001

以上是关于powershell 文件夹清理的主要内容,如果未能解决你的问题,请参考以下文章

powershell UT3重复配置文件清理

使用 Powershell 清理孤立的 Active Directory 用户配置文件文件夹

powershell [删除包,bin和obj文件夹删除包,bin和obj资料夹]用来快速清理解决方案里面非必要档案减少空间#powershell

powershell 清理Imsim安装(Windows)

powershell 在SysPrep之前清理图像

PowerShell - 使用 WebDAV 下载文件