-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-WindowsFabricLogSize.ps1
67 lines (54 loc) · 2.43 KB
/
Get-WindowsFabricLogSize.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
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
60
61
62
63
64
65
66
67
# 0.3
# Gathers the windows fabric log file Size of a Lync 2013 Server
# Use at your own risk. Test before using in production
# Assumes windows Fabric is on C:\
$VerbosePreference = 'Continue'
$FinalOutput = @()
Get-CsPool |
Where-Object -FilterScript {
$_.Services -like '*UserServer*'
} |
Select-Object -ExpandProperty Computers |
ForEach-Object -Process {
Write-Verbose -Message "Testing $_"
$TestPath = $null
$TestPath2 = $null
# Note, No Windows Fabric on 2010 Poool, Test_Path Coveres this, since the path does not exist on a 2010 server
$Path1 = "\\$_\C$\ProgramData\Windows Fabric\Fabric\log\Traces"
$TestPath = Test-Path -Path "$Path1"
Write-Verbose -Message "Test Path 1 Result: $TestPath"
# Alternate Path
$Path2 = "\\$_\c$\ProgramData\Windows Fabric\Log\Traces"
$TestPath2 = Test-Path -Path "$path2"
Write-Verbose -Message "Test Path 2 Result: $TestPath2"
If ($TestPath)
{
$Size = Get-ChildItem -Path "$Path1" | Measure-Object -Property length -Sum
$Path = $Path1
$FolderSizeMB = $Size.sum / 1MB
$FolderSizeMB = [Math]::Round($FolderSizeMB,2)
Write-Verbose -Message "Server $_"
Write-Verbose -Message "Path $Path"
Write-Verbose -Message "Size $FolderSizeMB MB"
$output = New-Object -TypeName PSobject
$output | Add-Member -MemberType NoteProperty -Name 'Computer' -Value $_
$output | Add-Member -MemberType NoteProperty -Name 'WinFabricLogSizeMB' -Value $FolderSizeMB
$FinalOutput += $output
}
If ($TestPath2)
{
$Size = Get-ChildItem -Path "$Path2" | Measure-Object -Property length -Sum
$Path = $Path2
$FolderSizeMB = $Size.sum / 1MB
$FolderSizeMB = [Math]::Round($FolderSizeMB,2)
Write-Verbose -Message "Server $_"
Write-Verbose -Message "Path $Path"
Write-Verbose -Message "Size $FolderSizeMB MB"
$output = New-Object -TypeName PSobject
$output | Add-Member -MemberType NoteProperty -Name 'Computer' -Value $_
$output | Add-Member -MemberType NoteProperty -Name 'WinFabricLogSizeMB' -Value $FolderSizeMB
$FinalOutput += $output
}
} # Close Foreach-Object
$FinalOutput | Format-Table -AutoSize