Functions/Step-ExPerfwizSize.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
Function Step-ExPerfwizSize {
    <#
 
    .SYNOPSIS
    Increases the max size of the experfwiz file by 1
 
    .DESCRIPTION
    To work around an issue with where start-experfwiz might fail this will increament the max size by 1mb
 
    .PARAMETER Name
    Name of the Data Collector set
 
    Default Exchange_Perfwiz
 
    .PARAMETER Server
    Name of the server
 
    Default LocalHost
 
    .OUTPUTS
    none
 
    .EXAMPLE
    Increase the max size of the default local experfwiz by 1
 
    Step-ExperfWizSize
 
    .EXAMPLE
    Increase the max size of a named remote experfwiz by 1
 
    Step-ExPerfwizSize -Name "My Collector Set" -Server RemoteServer-01
 
    #>


    [cmdletbinding()]
    param (
        [string]
        $Name = "Exchange_Perfwiz",

        [string]
        $Server = $env:ComputerName
    )

    # Step up the size of the perfwiz by 1
    $perfmon = Get-ExPerfwiz -Name $Name -Server $Server
    $newSize = $perfmon.maxsize + 1

    # increment the size
    [string]$logman = $null
    [string]$logman = logman update -name $Name -s $Server -max $newSize

    # If we find an error throw
    # Otherwise nothing
    if ($logman | select-string "Error:") {      
        Write-Logfile -string "[ERROR] - Problem stepping perfwize size:"
        Write-Logfile -string $logman
        Throw $logman
    }
    else {}
}