PowerShell: Recycle Bin'i tühjendamise skript

From ICO wiki
Revision as of 13:40, 22 May 2012 by Iliivik (talk | contribs)
(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

#>

  1. käivitab prügikasti.

$objShell = New-Object -Comobject Shell.Application

  1. Prügikast.

$objFolder = $objShell.Namespace(0xA)

  1. Tühjendab prügikasti, ajaperioodiga.

$objFolder.items() | where-object { $_.ModifyDate -lt (Get-Date).AddDays(-30) }

| %{ remove-item $_.path -Recurse -ErrorAction SilentlyContinue  -Force}