-
Notifications
You must be signed in to change notification settings - Fork 0
/
supermetriccheck.ps1
69 lines (48 loc) · 2.15 KB
/
supermetriccheck.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
68
69
Param (
[parameter(Mandatory=$true)][string]$username,
[parameter(Mandatory=$true)][string]$authsource,
[parameter(Mandatory=$true)][string]$source,
[parameter(Mandatory=$true)][string]$target,
[parameter(Mandatory=$true)][string]$environment,
[parameter(Mandatory=$false)][switch]$showall,
[parameter(Mandatory=$true)][string]$outputfile
)
Clear
if ($environment -eq 'live') {
import-module 'd:\scripts\vrops\powervrops\powervrops.psm1'
}
elseif ($environment -eq 'dev') {
import-module 'c:\users\taguser\documents\github\powervrops\powervrops.psm1'
}
$password = ([Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR((read-host 'Password: ' -assecurestring))))
$sourcetoken = acquireToken -resthost $source -username $username -password $password -authSource $authSource
$targettoken = acquireToken -resthost $target -username $username -password $password -authSource $authSource
$sourcesupermetrics = getsupermetrics -token $sourcetoken -resthost $source
$targetsupermetrics = getsupermetrics -token $targettoken -resthost $target
#$sourcesupermetrics.supermetrics
#$targetsupermetrics.superMetrics
foreach ($supermetric in $sourcesupermetrics.supermetrics) {
#write-host "in here"
$foundsm = $false
foreach ($targetsupermetric in $targetsupermetrics.superMetrics) {
# write-host "also in here"
if ($supermetric.id -eq $targetsupermetric.id) {
if ($supermetric.formula -eq $targetsupermetric.formula) {
if ($showall) {
write-host ($supermetric.name + ": ") -nonewline; write-host -foregroundcolor green "Supermetrics match"
}
else {
}
}
else {
write-host ($supermetric.name + ": ") -nonewline; write-host -foregroundcolor yellow "supermetrics don't match"
}
$foundsm = $true
Break
}
}
if ($foundsm -eq $false)
{
write-host ($supermetric.name + ": ") -nonewline; write-host -foregroundcolor red "Supermetric not found in target vrops instance"
}
}