PSScripts/Get-OSTFileSize.ps1

27 lines
715 B
PowerShell
Raw Normal View History

2023-12-18 18:01:19 +00:00
# Generates a list of all user's OST file sizes
$UserFolder = "C:\Users"
$OutlookFolder = "AppData\Local\Microsoft\Outlook"
class OST {
[string]$name
[float]$size
}
Get-ChildItem -Path $UserFolder | ForEach-Object {
$User = $_
$Folder = "$User\$OutlookFolder"
if ($(Test-Path -Path $Folder)){
$FoundFiles = Get-ChildItem $Folder -Filter *.ost | Where-Object {$_.Length / 1GB -gt 1}
$FoundFiles | Select-Object FullName, Length | ForEach-Object {
$Name = $_.FullName
$Size = [Math]::Round(($_.Length / 1GB), 2)
$ost = [OST]::new()
$ost.name = $Name
$ost.size = $Size
}
}
}
$ost