-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArchive Finder.ps1
27 lines (25 loc) · 1.03 KB
/
Archive Finder.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$query = "SELECT System.ItemName, system.ItemPathDisplay, System.ItemTypeText,
System.Size FROM SystemIndex where CONTAINS(System.fileExtension,'.pst')"
$objConnection = New-Object -ComObject adodb.connection
$objrecordset = New-Object -ComObject adodb.recordset
$objconnection.open(
"Provider=Search.CollatorDSO;Extended Properties='Application=Windows';")
$objrecordset.open($query, $objConnection)
Try { $objrecordset.MoveFirst() }
Catch [system.exception] { "no records returned" }
do
{
Write-host ($objrecordset.Fields.Item("System.ItemName")).value `
($objrecordset.Fields.Item("System.ItemPathDisplay")).value `
($objrecordset.Fields.Item("System.ITemTypeText")).value `
($objrecordset.Fields.Item("System.Size")).value
$total+= ($objrecordset.Fields.Item("System.size")).value
if(-not($objrecordset.EOF)) {$objrecordset.MoveNext()}
} Until ($objrecordset.EOF)
write-host ($total, "KB")
$total=0;
$objrecordset.Close()
$objConnection.Close()
$objrecordset = $null
$objConnection = $null
[gc]::collect()