-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-OST.ps1
More file actions
59 lines (34 loc) · 1.27 KB
/
Copy pathGet-OST.ps1
File metadata and controls
59 lines (34 loc) · 1.27 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#get ost file
function Get-OST {
param (
[string]$Computer
)
$OSTFiles = Get-ChildItem "\\$Computer\C$\Users\*\AppData\Local\Microsoft\Outlook\*.ost" -ErrorAction SilentlyContinue
if ($OSTFiles.Count -eq 0) {
Write-Host "No OST files found on $Computer."
return
}
$OSTFilesList = @()
foreach ($OSTFile in $OSTFiles) {
$OSTFilesList += [PSCustomObject]@{
FilePath = $OSTFile.FullName
FileName = $OSTFile.Name
FileSize = [math]::Round(($OSTFile.Length / 1MB), 2)
}
}
Write-Host "OST files found on $Computer"
$i = 0
foreach ($OST in $OSTFilesList) {
Write-Host "$i. $($OST.FileName) - $($OST.FileSize) MB"
$i++
}
$selection = Read-Host "Enter the number of the OST file to remove"
if ($selection -ge 0 -and $selection -lt $OSTFilesList.Count) {
$OSTFileToRemove = $OSTFilesList[$selection]
Write-Host "Removing $($OSTFileToRemove.FileName)..."
Remove-Item -Path $OSTFileToRemove.FilePath -Force
Write-Host "OST file $($OSTFileToRemove.FileName) has been removed."
} else {
Write-Host "Invalid selection."
}
}