PowerShell: Recycle Bin'i tühjendamise skript

From ICO wiki
Revision as of 13:39, 22 May 2012 by Iliivik (talk | contribs) (Created page with '<Source lang="powershell"> <# .SYNOPSIS Prügikasti tühjendamise skript .DESCRIPTION Kustutab prügikastist failid, mida ei ole 30 päeva jooksul muudetud. .Exampl…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

<Source lang="powershell">

<#

.SYNOPSIS Prügikasti tühjendamise skript

.DESCRIPTION Kustutab prügikastist failid, mida ei ole 30 päeva jooksul muudetud.

.Example

	 C:\PS>.\RecycleBin.ps1 

.NOTES

	 Autor: Iti Liivik
	 Versioon: 0.1
	 Muutmise kuup2ev 22.05.2012

.LINK http://enos.itcollege.ee/~iliivik

#>

$objShell = New-Object -Comobject Shell.Application #käivitab prügikasti. $objFolder = $objShell.Namespace(0xA) #Prügikast.

  1. Tühjendab prügikasti, ajaperioodiga.

$objFolder.items() | where-object { $_.ModifyDate -lt (Get-Date).AddDays(-30) } | %{ remove-item $_.path -Recurse -ErrorAction SilentlyContinue -Force}