-
Notifications
You must be signed in to change notification settings - Fork 10
/
Get-TraverseTestHistoricalDataBatch.ps1
56 lines (51 loc) · 2.14 KB
/
Get-TraverseTestHistoricalDataBatch.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
#requires -version 3
#requires -module Traverse
#requires -module ImportExcel
[CmdletBinding()]
param (
#Which Devices to gather history for. Use * for all devices. Regex expressions are supported
[Parameter(ValueFromPipeline)]$devicename = '*',
#Which user to scope the report to. Requires superuser
$user,
#Time Range Start. Defaults to last month
$historyStart = (get-date -day 1 -hour 0 -minute 0 -second 0).addmonths(-1),
#Time Range Start. Defaults to last month
$historyEnd = $historyStart.AddMonths(1)
)
begin {
#This script requires COnvertTo-FlatObject.ps1 to be in the path
Invoke-command {& ConvertTo-Flatobject.ps1} -ErrorAction Stop
if ($user) {
if ((invoke-traversecommand -api rest 'whoami').data.object.loginname -notmatch $user) {
#Switch to usercontext (requires superuser)
$representResult = invoke-traversecommand -api REST 'user.represent' -argumentlist @{loginName="$user"} -ErrorAction stop
}
}
}
process {
foreach ($devicename in $devicename) {
$cputests = @(get-traversetest -subtype cpu -devicename $devicename | where testName -match 'Overall CPU Load')
$disktests = @(get-traversetest -subtype disk -devicename $devicename)
$memtests = @(get-traversetest -subtype phymemory -devicename $devicename)
$reportTests = $cputests + $disktests + $memtests
$i = 1
$reportTests |
foreach {
write-progress -activity "Gathering Historical Data ($i of $($reportTests.count))" -status $_.testname -currentoperation $_.deviceName -PercentComplete (($i/$reportTests.count)*100)
Get-TraverseTestRawHistoricalData -Start $historyStart -end $historyEnd -TestSerial $_.serialNumber -verbose
$i++
} |
foreach {
$PSItem | select accountName,
deviceName,
testName,
percentile98,
percentile95,
mean,
stdDev,
minValue,
maxValue,
units
}
}
}