#Manage-OutlookAttachmentFolder.ps1 #Alan dot Kaplan at va dot gov #12-17-15 Function Get-FileSizeString ($len){ switch ($len) { {$_ -ge 1TB} { "{0:n2}" -f ($_ / 1TB) + " TB";Break} {$_ -ge 1GB} { "{0:n2}" -f ($_ / 1GB) + " GB";Break} {$_ -ge 1000KB} { "{0:n2}" -f ($_ / 1MB) + " MB";Break} Default {"{0:n2}" -f ($_ / 1KB) + " KB"} } } Function Choose-FolderDialog{ Param ( # [Parameter(Mandatory=$False)] $RootFolder='MyComputer', [Parameter(Mandatory=$false)] [bool]$NewFolderBtn=$true, [Parameter(Mandatory=$false)] [string]$Title="" ) Add-Type -AssemblyName System.Windows.Forms $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{ RootFolder = $RootFolder ShowNewFolderButton = $NewFolderBtn Description = $Title } $Show = $FolderBrowser.ShowDialog() If ($Show -eq "OK") { Return $FolderBrowser.SelectedPath } Else { Write-warning "Operation cancelled by user." } } $List = gci "$env:UserProfile\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\" -file -Recurse | Select Name, LastWriteTime, length, @{Name="FileSize";Expression={Get-FileSizeString $_.length }}, FullName | out-gridview -Title "Select Item(s), then `"OK`" to choose `"Delete`" or `"Move`" actions" -passthru Add-Type -assemblyname Microsoft.visualBasic $msg = " 1) Delete item(s) in list 2) Move item(s) 0) Quit " [int]$Retval = [Microsoft.VisualBasic.Interaction]::InputBox($Msg, "Choose Action", 0) switch ($Retval) { 1 { $list | foreach { $msg = "Deleting " + $_.Name Write $msg Remove-Item $_.Fullname -Force } } 2 { $DestFolder = Choose-FolderDialog -RootFolder Desktop -NewFolderBtn:$True -Title "Move files here:" if (Test-Path $DestFolder){ $list |foreach { $msg = "Moving " + $_.Name + " to $destfolder" Write $msg Move-Item $_.fullname -Destination $destfolder } }Else{Exit} } Default {Exit} }