-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGet-PublicFolderStats.ps1
More file actions
55 lines (39 loc) · 1.64 KB
/
Get-PublicFolderStats.ps1
File metadata and controls
55 lines (39 loc) · 1.64 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
param(
[string[]]$ComputerName = @(),
[switch]$Reload
)
if (-not $ComputerName.Count -gt 0)
{
$ComputerName = @("SERVER01","SERVER02","SERVER03")
}
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
$DateStamp = Get-Date -Format "yyyy-MM-dd"
foreach($server in $ComputerName) {
$server = $server.ToUpper()
$StatsFileName = "$($DateStamp)-PF-Stats-$($server).xml"
$StatsFile = Join-Path -Path $ScriptDir -ChildPath $StatsFileName
Write-Host "Saving public folder stats to: $StatsFile"
if(!(Test-Path $StatsFile) -or $Reload) {
Write-Host "> File does not exist! Load stats from $($server)"
# $stats = Get-PublicFolder "\" -Recurse | Get-PublicFolderStatistics -Server $server
$stats = Get-PublicFolderStatistics -Server $server -ResultSize Unlimited -ErrorAction SilentlyContinue
$stats | Export-Clixml -Path $StatsFile -Force
}
else {
Write-Host "> File exists, nothing to do!"
}
}
foreach($server in $ComputerName) {
$server = $server.ToUpper()
$PubFileName = "$($DateStamp)-PF-Data-$($server).xml"
$PubFile = Join-Path -Path $ScriptDir -ChildPath $PubFileName
Write-Host "Saving public data: $PubFile"
if(!(Test-Path $PubFile) -or $Reload) {
Write-Host "> File does not exist! Load public folder from $($server)"
$pub = Get-PublicFolder -Server $server -Recurse -ResultSize Unlimited -ErrorAction SilentlyContinue
$pub | Export-Clixml -Path $PubFile -Force -Encoding UTF8
}
else {
Write-Host "> File exists, nothing to do!"
}
}