# encoding: ascii
# api: powershell
# title: Deleted-Objects
# description: Remove the folder or folders from computer on your network.
# version: 0.1
# author: Angel-Keeper
# license: CC0
# x-poshcode-id: 1896
# x-archived: 2017-05-22T04:49:41
# x-published: 2011-06-03T16:12:00
#
#
param (
$Computer,
[String[]]$ObjectsDeleted
)

$Info = $null
$Disks = $null

trap {Write-Host "Error WmiObject $Computer";Continue}
$Disks += Get-WmiObject win32_logicaldisk -ComputerName $Computer | 
		  Where-Object {$_.Size -ne $null}

foreach ($Disk in $Disks){
	
	if ($Disk.Name -like "*:*") {
	$Disk = $Disk.Name.Replace(":","$")
	}
	
	trap {Write-Host "Error ChildItem $Computer";Continue}
	$Info += Get-ChildItem "\\$Computer\$Disk\*" -Recurse -ErrorAction SilentlyContinue
		
	if ($Info){
		
		foreach ($Object in $ObjectsDeleted){
			$Info | Where-Object {$_.Name -like $Object} | 
					% {remove-item $_.fullname -Recurse -Force -ErrorAction SilentlyContinue}
		}
	}
}
