PowerShell: Recycle Bin'i tühjendamise skript: Difference between revisions

From ICO wiki
Jump to navigationJump to search
(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…')
 
No edit summary
 
Line 21: Line 21:
    
    
#>
#>
 
#käivitab prügikasti.
$objShell = New-Object -Comobject Shell.Application #käivitab prügikasti.
$objShell = New-Object -Comobject Shell.Application  
$objFolder = $objShell.Namespace(0xA) #Prügikast.
#Prügikast.
$objFolder = $objShell.Namespace(0xA)  
#Tühjendab prügikasti, ajaperioodiga.
#Tühjendab prügikasti, ajaperioodiga.
$objFolder.items() | where-object { $_.ModifyDate -lt (Get-Date).AddDays(-30) }  | %{ remove-item $_.path -Recurse -ErrorAction SilentlyContinue  -Force}
$objFolder.items() | where-object  
{  
$_.ModifyDate -lt (Get-Date).AddDays(-30) }  
  | %{ remove-item $_.path -Recurse -ErrorAction SilentlyContinue  -Force}

Latest revision as of 14:40, 22 May 2012

<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}