-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-VMPerformanceDefinition.ps1
More file actions
1089 lines (1022 loc) · 60.1 KB
/
New-VMPerformanceDefinition.ps1
File metadata and controls
1089 lines (1022 loc) · 60.1 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
.SYNOPSIS
Creates Nagios monitoring configurations for Hyper-V virtual machines.
.DESCRIPTION
Scans one or more virtual machines and generates Nagios sensors for performance checks.
Each check is expressed as a "service". A suitable "check-hypervmperf" command must already exist.
.PARAMETER VM
One or more virtual machines. Each input item will be scanned and included in the output file.
Accepts multiple input types:
* Microsoft.HyperV.PowerShell.VirtualMachine: This object type is output by the native Get-VM cmdlet. ComputerName is ignored with this type.
* System.String: Assumed to be the name of the target virtual machine. Used in conjunction with ComputerName.
* Microsoft.Management.Infrastructure.CimInstance: This type is output by Get-CimInstance. Must have a CreationClassName of Msvm_ComputerSystem. ComputerName is ignored with this type.
* System.Management.ManagementObject: This type is output by Get-WmiObject. Expected to be of type Msvm_ComputerSystem; must have a Name property that contains the VMId of a virtual machine on the objects __SERVER property to be effective. ComputerName is ignored with this type.
* Nothing: If not specified, will scan ComputerName for virtual machines.
.PARAMETER ComputerName
The target computer system to scan for virtual machines.
Ignored if VM is anything other than a string (including an empty string or an array of strings).
If a cluster name or IP is specified, only the current owner of the core cluster resource will be scanned.
If not specified, the local system is used.
.PARAMETER Path
The path to a base output filename. It will be used as a template. Generated files will have an underscore and a number.
Ex: "C:\temp\vdidef" becomes "C:\temp\vdidef_perf1.cfg", "C:\temp\vdidef_perf2.cfg", etc.
.PARAMETER LineEndFormat
Specifies the system codes to use to indicate an end-of-line in the output file. Default is "Linux".
* Linux: Uses only a newline character (\n)
* Windows: Uses a carriage-return/newline character combination (\r\n)
* Macintosh: Uses only a carriage-return character (\r)
.PARAMETER ServiceTemplate
Text to include on each service's "use" line. Defaults to "generic-service".
.PARAMETER ServiceGroups
Text to include on each service's "servicegroups" line. If left empty, no "servicegroups" line will be generated.
.PARAMETER ServiceContacts
Text to use as a service's "contacts" line. If left empty, the "contacts" line is not generated.
.PARAMETER ServiceContactGroups
Text to use as a service's "contact_groups" line. If left empty, the "contact_groups" line is not generated.
.PARAMETER ResolveHost
Determines the IP address of the Hyper-V host or cluster and uses that as the service target instead of the host name.
.PARAMETER VMAsHost
Default behavior will assign the Hyper-V host or cluster as the service's "host_name". If VMAsHost is specified, uses the VM's name instead.
.PARAMETER UpperCaseHostName
Nagios' host_names are case sensitive. The techniques used in this script will alwoys generate lower-case names. Specify UpperCaseHostNames to force them to uppercase.
.PARAMETER SkipCPU
If specified, does not include any virtual CPU sensors.
.PARAMETER SkipDynamicMemory
If specified, does not include any dynamic memory sensors. Unnecessary for fixed memory virtual machines.
.PARAMETER SkipDisk
If specified, does not generate any virtual hard disk sensors. Unnecessary for diskless virtual machines. Operates independently of SkipIDE.
.PARAMETER SkipNetwork
If specified, does not generate any virtual network sensors.
.PARAMETER IncludeAdvancedCounters
If specified, includes several uncommon and advanced counters in each category.
.PARAMETER IncludeIDE
If specified, includes emulated IDE sensors. Generally reads 0. Not useful for Generation 2 virtual machines. Operates independently of SkipDisk.
.PARAMETER IncludeLiveMigration
If specified, includes LiveMigration-related counters. Unnecessary for non-clustered virtual machines.
.PARAMETER IncludeSavesSnaps
If specified, includes counters related to Save and Snapshot/Checkpoint operations.
.PARAMETER IncludeSmartPaging
If specified, includes counters related to Smart Paging operations.
.PARAMETER IncludeNUMA
If specified, includes counters related to NUMA.
.PARAMETER IncludeNetworkDropReasons
If specified, includes counters for network drop reasons. Ignored if host is not 2016.
.PARAMETER IncludeVmWorkerProcess
If specified, includes counters for VM worker processors. Ignored if host is not 2016.
.PARAMETER IncludeVRSS
If specified, includes vRSS counters for all virtual network adapters on 2016 VMs.
.PARAMETER CreateVMHostDefinition
If specified, generates a host{} definition for each virtual machine. Ignored if VMAsHost is not also set.
The generated host definition will include the following lines unless you specify a VMHostTemplate:
max_check_attempts 1
check_command null
notifications_enabled 0
.PARAMETER VMHostTemplate
Text to use as a host's "use" line. Defaults to "generic-host". Ignored if CreateVMHostDefinition and VMAsHost are not also set.
.PARAMETER UseSkeletonHost
If specified, will force the inclusion of the default items indicated in the description of CreateVMHostDefinition, even when VMHostTemplate is set.
Ignored if CreateVMHostDefinition and VMAsHost are not also set.
.PARAMETER VMHostGroups
Text to use as a host's "hostgroups" line. If left empty, the "hostgroups" line is not generated. Ignored if CreateVMHostDefinition and VMAsHost are not also set.
.PARAMETER VMHostContacts
Text to use as a host's "contacts" line. If left empty, the "contacts" line is not generated. Ignored if CreateVMHostDefinition and VMAsHost are not also set.
.PARAMETER VMHostContactGroups
Text to use as a host's "contact_groups" line. If left empty, the "contact_groups" line is not generated. Ignored if CreateVMHostDefinition and VMAsHost are not also set.
.PARAMETER VMsPerFile
Maximum number of VMs to place in each service definition file. All counters for a virtual machine will appear in the same file.
.INPUTS
System.String[]
Microsoft.HyperV.PowerShell.VirtualMachine[]
Microsoft.Management.Infrastructure.CimInstance[]
System.Management.ManagementObject[]
.OUTPUTS
None
.NOTES
New-VMPerformanceDefinition.ps1
Author: Eric Siron
.EXAMPLE
New-VMPerformanceDefinition.ps1 -ComputerName -Path C:\Source\svhv01.cfg -ServiceTemplate 'hyperv-vm-performance'
Creates a basic sensor set from all virtual machines on the host named svhv01 using the defined service template.
.EXAMPLE
Get-CimInstance -ComputerName svhv01 -ClassName msvm_computersystem -Namespace root/virtualization/v2 -Filter 'ElementName="dtmanage"' | New-VMPerformanceDefinition.ps1 -Path C:\Source\dtmanage.cfg -ServiceTemplate 'hyperv-vm-performance' -VMAsHost -IncludeAdvancedCounters -IncludeLiveMigration -IncludeSavesSnaps -IncludeSmartPaging -IncludeNUMA -IncludeNetworkDropReasons -IncludeVmWorkerProcess -IncludeVRSS -IncludeRemotingChecks -CreateVMHostDefinition
Retrieves the CIM definition from a host named "svhv01" for the virtual machine named "dtmanage" and creates a .cfg file with all possible counters.
#>
#requires -Version 4
[CmdletBinding()]
param(
[Parameter(Position = 1, ValueFromPipeline = $true)][System.Object[]]$VM,
[Parameter()][String]$ComputerName = $env:COMPUTERNAME,
[Parameter(Position = 2, Mandatory = $true)][String]$Path,
[Parameter()][ValidateSet('2012R2', '2016')][String]$Version,
[Parameter()][ValidateSet('Linux', 'Windows', 'Macintosh')][String]$LineEndFormat = 'Linux',
[Parameter()][String]$ServiceTemplate = 'generic-service',
[Parameter()][String]$ServiceGroups = [System.String]::Empty,
[Parameter()][String]$ServiceContacts = [System.String]::Empty,
[Parameter()][String]$ServiceContactGroups = [System.String]::Empty,
[Parameter()][Switch]$ResolveHost,
[Parameter()][Switch]$VMAsHost,
[Parameter()][Switch]$UpperCaseHostName,
[Parameter()][Switch]$SkipCPU,
[Parameter()][Switch]$SkipDynamicMemory,
[Parameter()][Switch]$SkipDisk,
[Parameter()][Switch]$SkipNetwork,
[Parameter()][Switch]$IncludeAdvancedCounters,
[Parameter()][Switch]$IncludeIDE,
[Parameter()][Switch]$IncludeLiveMigration,
[Parameter()][Switch]$IncludeSavesSnaps,
[Parameter()][Switch]$IncludeSmartPaging,
[Parameter()][Switch]$IncludeNUMA,
[Parameter()][Switch]$IncludeNetworkDropReasons,
[Parameter()][Switch]$IncludeVmWorkerProcess,
[Parameter()][Switch]$IncludeVRSS,
[Parameter()][Switch]$IncludeRemotingChecks,
[Parameter()][Switch]$CreateVMHostDefinition,
[Parameter()][String]$VMHostTemplate = 'generic-host',
[Parameter()][Switch]$UseSkeletonHost,
[Parameter()][String]$VMHostGroups = [System.String]::Empty,
[Parameter()][String]$VMHostContacts = [System.String]::Empty,
[Parameter()][String]$VMHostContactGroups = [System.String]::Empty,
[Parameter()][Int32]$VMsPerFile = 50
)
begin
{
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
$GUIDPattern = '[0-9a-fA-F]{8}.?[0-9a-fA-F]{4}.?[0-9a-fA-F]{4}.?[0-9a-fA-F]{4}.?[0-9a-fA-F]{12}'
$CounterList = New-Object -TypeName System.Collections.ArrayList
$VMList = New-Object -TypeName System.Collections.ArrayList
$LineEnding = [String]::Empty
if (-not (Test-Path -Path $Path))
{
try
{
$TempFile = New-Item -Path $Path -ItemType File -ErrorAction Stop
}
catch
{
Write-Error -Message ('Unable to create file {0}: {1}' -f $Path, $_.Exception.Message)
exit 1
}
Remove-Item -Path $TempFile
}
if ($VMsPerFile -le 0)
{
$VMsPerFile = 50
}
function New-ServiceObject
{
param(
[Parameter()][String]$HostName,
[Parameter()][String]$VMName,
[Parameter()][String]$CounterCategory,
[Parameter()][String]$Counter,
[Parameter()][bool]$Clustered
)
$ServiceItem = New-Object -TypeName psobject
Add-Member -InputObject $ServiceItem -MemberType NoteProperty -Name 'HostName' -Value $HostName
Add-Member -InputObject $ServiceItem -MemberType NoteProperty -Name 'VMName' -Value $VMName
Add-Member -InputObject $ServiceItem -MemberType NoteProperty -Name 'CounterName' -Value ([String]::Join(' ', $CounterCategory, ($Counter.Substring($Counter.LastIndexOf('\') + 1).Replace('%', 'Pct') -replace '([\(\)])', '')))
Add-Member -InputObject $ServiceItem -MemberType NoteProperty -Name 'Counter' -Value $Counter
Add-Member -InputObject $ServiceItem -MemberType NoteProperty -Name 'Clustered' -Value $Clustered
$ServiceItem
}
function New-ServiceDefinition
{
param(
[Parameter()][Object]$ServiceObject,
[Parameter()][String]$LineEnding,
[Parameter()][String]$ServiceTemplate,
[Parameter()][String]$ServiceGroups,
[Parameter()][String]$ServiceContacts,
[Parameter()][String]$ServiceContactGroups,
[Parameter()][bool]$VMAsHost
)
$ExtraCommands = ''
if ($ServiceObject.Clustered)
{
$ExtraCommands = '-l'
}
$ServiceText = New-Object System.Text.StringBuilder
$OutNull = $ServiceText.AppendFormat('define service{{{0}', $LineEnding)
$OutNull = $ServiceText.AppendFormat(' use {0}{1}', $ServiceTemplate, $LineEnding)
if ($VMAsHost)
{
$OutNull = $ServiceText.AppendFormat(' service_description {0}{1}', $ServiceObject.CounterName, $LineEnding)
$TargetHost = $ServiceObject.VMName
}
else
{
$OutNull = $ServiceText.AppendFormat(' service_description {0} {1}{2}', $ServiceObject.VMName, $ServiceObject.CounterName, $LineEnding)
$TargetHost = $ServiceObject.HostName
}
$OutNull = $ServiceText.AppendFormat(' host_name {0}{1}', $TargetHost, $LineEnding)
if ($ServiceGroups)
{
$OutNull = $ServiceText.AppendFormat(' servicegroups {0}{1}', $ServiceGroups, $LineEnding)
}
if ($ServiceContacts)
{
$OutNull = $ServiceText.AppendFormat(' contacts {0}{1}', $ServiceContacts, $LineEnding)
}
if ($ServiceContactGroups)
{
$OutNull = $ServiceText.AppendFormat(' contact_groups {0}{1}', $ServiceContactGroups, $LineEnding)
}
$OutNull = $ServiceText.AppendFormat(' check_command check-hypervmperf!{0}!{1}!"{2}"!{3}{4}', $ServiceObject.HostName, $ServiceObject.VMName, $ServiceObject.Counter, $ExtraCommands, $LineEnding)
$OutNull = $ServiceText.AppendFormat('}}{0}', $LineEnding)
$ServiceText.ToString()
}
function New-HostDefinition
{
param(
[Parameter()][String]$ComputerName,
[Parameter()][String]$HostTemplate,
[Parameter()][String]$VMHostGroups,
[Parameter()][String]$VMHostContacts,
[Parameter()][String]$VMHostContactGroups,
[Parameter()][bool]$UseSkeletonHost,
[Parameter()][String]$LineEnding
)
$HostText = New-Object System.Text.StringBuilder
$OutNull = $HostText.AppendFormat('define host{{{0}', $LineEnding)
$OutNull = $HostText.AppendFormat(' host_name {0}{1}', $ComputerName, $LineEnding)
$OutNull = $HostText.AppendFormat(' use {0}{1}', $HostTemplate, $LineEnding)
if (($HostTemplate -eq 'generic-host') -or $UseSkeletonHost)
{
$OutNull = $HostText.AppendFormat(' max_check_attempts 1{0}', $LineEnding)
$OutNull = $HostText.AppendFormat(' check_command null{0}', $LineEnding)
$OutNull = $HostText.AppendFormat(' notifications_enabled 0{0}', $LineEnding)
}
if ($VMHostGroups)
{
$OutNull = $HostText.AppendFormat(' hostgroups {0}{1}', $VMHostGroups, $LineEnding)
}
if ($VMHostContacts)
{
$OutNull = $HostText.AppendFormat(' contacts {0}{1}', $VMHostContacts, $LineEnding)
}
if ($VMHostContactGroups)
{
$OutNull = $HostText.AppendFormat(' contact_groups {0}{1}', $VMHostContactGroups, $LineEnding)
}
$OutNull = $HostText.AppendFormat('}}{0}', $LineEnding)
$HostText.ToString()
}
$AdvancedChecks = @(
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Skipped Timer Ticks',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Device Interrupt Throttle Events',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Device DMA Errors',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Device Interrupt Errors',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\I/O TLB Flush Cost',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\I/O TLB Flushes/sec',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Device Interrupt Mappings',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Attached Devices',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\1G device pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\2M device pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\4K device pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\1G GPA pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\2M GPA pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\4K GPA pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Recommended Virtual TLB Size',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Virtual TLB Flush Entires/sec',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\GPA Space Modifications/sec',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\GPA Pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Deposited Pages',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Address Spaces',
'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Virtual TLB Pages'
#'\\Hyper-V Hypervisor Partition({0}:HvPt)\\Virtual Processors'
)
$AdvancedChecks2016 = @(
'\\Hyper-V Hypervisor Partition(dtmanage:HvPt)\\Nested TLB Trimmed Pages/sec',
'\\Hyper-V Hypervisor Partition(dtmanage:HvPt)\\Nested TLB Free List Size',
'\\Hyper-V Hypervisor Partition(dtmanage:HvPt)\\Recommended Nested TLB Size',
'\\Hyper-V Hypervisor Partition(dtmanage:HvPt)\\Nested TLB Size'
)
$CPUCoreChecks = @(
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\% Guest Run Time'
)
$CPUAdvancedChecks = @(
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\% Remote Run Time',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Total Intercepts Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Total Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Total Messages/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\% Hypervisor Run Time',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\% Total Run Time',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\CPU Wait Time Per Dispatch',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Logical Processor Dispatches/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested Page Fault Intercepts Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested Page Fault Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Hardware Interrupts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Virtual Processor Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Virtual MMU Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Virtual Interrupt Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Synthetic Interrupt Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Other Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Long Spin Wait Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Logical Processor Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\GPA Space Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\APIC Self IPIs Sent/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\APIC IPIs Sent/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Virtual Interrupts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Synthetic Interrupts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Table Write Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\APIC TPR Accesses/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Table Validations/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Table Resets/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Table Reclamations/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Table Evictions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Local Flushed GVA Ranges/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Global GVA Range Flushes/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Address Space Flushes/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Address Domain Flushes/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Address Space Switches/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Address Space Evictions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Logical Processor Migrations/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Table Allocations/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Other Messages/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\APIC EOI Accesses/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Memory Intercept Messages/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\IO Intercept Messages/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\APIC MMIO Accesses/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Reflected Guest Page Faults/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Small Page TLB Fills/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Large Page TLB Fills/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Guest Page Table Maps/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Fault Intercepts Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Fault Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Debug Register Accesses Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Debug Register Accesses/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Emulated Instructions Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Emulated Instructions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Pending Interrupts Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Pending Interrupts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\External Interrupts Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\External Interrupts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Other Intercepts Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Other Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MSR Accesses Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MSR Accesses/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\CPUID Instructions Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\CPUID Instructions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MWAIT Instructions Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MWAIT Instructions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\HLT Instructions Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\HLT Instructions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\IO Instructions Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\IO Instructions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Control Register Accesses Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Control Register Accesses/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Invalidations Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Invalidations/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Hypercalls Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Hypercalls/sec'
)
$CPUAdvanced2016Checks = @(
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Total Virtualization Instructions Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Total Virtualization Instructions Emulated/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Flush Physical Address List Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Flush Physical Address Space Hypercalls/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested TLB Page Table Evictions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested TLB Page Table Reclamations/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvVpid Single Address Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvVpid Single Address Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvVpid Single Context Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvVpid Single Context Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvVpid All Context Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvVpid All Context Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvEpt Single Context Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvEpt Single Context Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvEpt All Context Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\InvEpt All Context Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested SLAT Hard Page Faults Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested SLAT Hard Page Faults/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested SLAT Soft Page Faults Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested SLAT Soft Page Faults/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested VM Entries Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Nested VM Entries/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMXON Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMXON Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMXOFF Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMXOFF Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMWRITE Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMWRITE Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMREAD Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMREAD Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMPTRST Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMPTRST Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMPTRLD Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMPTRLD Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMCLEAR Instruction Emulation Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\VMCLEAR Emulation Intercepts/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Fault Intercepts Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Fault Intercepts Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Debug Register Accesses Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Debug Register Accesses Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Emulated Instructions Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Emulated Instructions Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Pending Interrupts Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Pending Interrupts Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\External Interrupts Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Other Intercepts Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Other Intercepts Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MSR Accesses Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MSR Accesses Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\CPUID Instructions Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\CPUID Instructions Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MWAIT Instructions Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MWAIT Instructions Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\HLT Instructions Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\HLT Instructions Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\IO Instructions Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\IO Instructions Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Control Register Accesses Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Control Register Accesses Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Invalidations Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Page Invalidations Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Hypercalls Forwarding Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Hypercalls Forwarded/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Local I/O TLB Flush Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Local I/O TLB Flushes/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Global I/O TLB Flush Cost',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Global I/O TLB Flushes/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Other Reflected Guest Exceptions/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\MBEC Nested Page Table Switches/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Extended Hypercall Intercept Messages/sec',
'\\Hyper-V Hypervisor Virtual Processor({0}:Hv VP {1})\\Extended Hypercalls/sec'
)
$DiskCoreChecks = @(
'\\Hyper-V Virtual Storage Device({0})\\Queue Length',
'\\Hyper-V Virtual Storage Device({0})\\Normalized Throughput',
'\\Hyper-V Virtual Storage Device({0})\\Write Operations/Sec',
'\\Hyper-V Virtual Storage Device({0})\\Read Operations/Sec',
'\\Hyper-V Virtual Storage Device({0})\\Write Bytes/sec',
'\\Hyper-V Virtual Storage Device({0})\\Read Bytes/sec'
)
$DiskAdvancedChecks = @(
'\\Hyper-V Virtual Storage Device({0})\\Error Count',
'\\Hyper-V Virtual Storage Device({0})\\Flush Count',
'\\Hyper-V Virtual Storage Device({0})\\Write Count',
'\\Hyper-V Virtual Storage Device({0})\\Read Count'
)
$DiskAdvanced2012R2Checks = @(
'\\Hyper-V Virtual Storage Device({0})\\Quota Replenishment Rate'
)
$DiskAdvanced2016Checks = @(
'\Hyper-V Virtual Storage Device({0})\\Maximum Bandwidth',
'\Hyper-V Virtual Storage Device({0})\\Byte Quota Replenishment Rate',
'\Hyper-V Virtual Storage Device({0})\\Io Quota Replenishment Rate',
'\Hyper-V Virtual Storage Device({0})\\Lower Latency',
'\Hyper-V Virtual Storage Device({0})\\Minimum IO Rate',
'\Hyper-V Virtual Storage Device({0})\\Maximum IO Rate',
'\Hyper-V Virtual Storage Device({0})\\Latency',
'\Hyper-V Virtual Storage Device({0})\\Throughput',
'\Hyper-V Virtual Storage Device({0})\\Lower Queue Length'
)
$DynamicMemoryChecks = @( # same for 2012R2 and 2016, but always works on 2016
'\\Hyper-V Dynamic Memory VM({0})\\Maximum Pressure',
'\\Hyper-V Dynamic Memory VM({0})\\Minimum Pressure',
'\\Hyper-V Dynamic Memory VM({0})\\Average Pressure',
'\\Hyper-V Dynamic Memory VM({0})\\Current Pressure'
)
$DynamicMemoryDMOnlyChecks = @(
'\\Hyper-V Dynamic Memory VM({0})\\Physical Memory',
'\\Hyper-V Dynamic Memory VM({0})\\Guest Visible Physical Memory'
)
$DynamicMemoryChecks2016 = @(
'\\Hyper-V Dynamic Memory VM({0})\\Memory Remove Operations',
'\\Hyper-V Dynamic Memory VM({0})\\Removed Memory',
'\\Hyper-V Dynamic Memory VM({0})\\Memory Add Operations',
'\\Hyper-V Dynamic Memory VM({0})\\Added Memory'
)
$IDEChecks = @(
'\\Hyper-V Virtual IDE Controller (Emulated)({0}:Ide Controller)\\Write Bytes/sec',
'\\Hyper-V Virtual IDE Controller (Emulated)({0}:Ide Controller)\\Read Bytes/sec',
'\\Hyper-V Virtual IDE Controller (Emulated)({0}:Ide Controller)\\Written Sectors/sec',
'\\Hyper-V Virtual IDE Controller (Emulated)({0}:Ide Controller)\\Read Sectors/sec'
)
$LiveMigrationChecks = @(
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Receiver: Decompressed Bytes/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Receiver: Maximum Threadpool Thread Count',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Receiver: Uncompressed Bytes Received/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Receiver: Bytes Pending Write',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Receiver: Bytes Written/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Memory Walker: Uncompressed Bytes Sent/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Memory Walker: Uncompressed Bytes Sent',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Memory Walker: Bytes Read/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Memory Walker: Maximum Threads',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\TCP Transport: Bytes Received/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\TCP Transport: Bytes Pending Processing',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\TCP Transport: Posted Receive Buffer Count',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\TCP Transport: Bytes Sent/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\TCP Transport: Bytes Pending Send',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\TCP Transport: Pending Send Count',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\TCP Transport: Total buffer count',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Transfer pass: CPU Cap',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Transfer pass: Dirty Page Count',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Transfer Pass: Is blackout',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Transfer Pass: Number'
)
$LiveMigrationCompressionChecks = @(
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Receiver: Bytes Pending Decompression',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Receiver: Compressed Bytes Received/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Memory Walker: Bytes Sent for Compression/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Memory Walker: Bytes Sent for Compression',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Compressor: Enabled Threads',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Compressor: Maximum Threads',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Compressor: Compressed Bytes Sent/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Compressor: Compressed Bytes Sent',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\Compressor: Bytes to be Compressed'
)
$LiveMigrationSMBChecks = @( # same for 2012R2 and 2016
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\SMB Transport: Bytes Sent/sec',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\SMB Transport: Bytes Sent',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\SMB Transport: Pending Send Bytes',
'\\Hyper-V VM Live Migration({0}:VM Live Migration)\\SMB Transport: Pending Send Count'
)
$NetworkCoreChecks = @(
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Bytes Sent/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Bytes Received/sec'
)
$NetworkAdvancedChecks = @(
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Extensions Dropped Packets Outgoing/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Extensions Dropped Packets Incoming/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Dropped Packets Outgoing/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Dropped Packets Incoming/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\IPsec offload Bytes Receive/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\IPsec offload Bytes Sent/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Directed Packets Sent/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Directed Packets Received/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Broadcast Packets Sent/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Broadcast Packets Received/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Multicast Packets Sent/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Multicast Packets Received/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Packets Sent/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Packets Received/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Packets/sec',
'\\Hyper-V Virtual Network Adapter({0}_Network Adapter_{1}--{2})\\Bytes/sec'
)
$NetworkDropReasonChecks = @(
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing LowPowerPacketFilter',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming LowPowerPacketFilter',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidPDQueue',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidPDQueue',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing FilteredIsolationUntagged',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming FilteredIsolationUntagged',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing SwitchDataFlowDisabled',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming SwitchDataFlowDisabled',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing FailedPacketFilter',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming FailedPacketFilter',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing NicDisabled',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming NicDisabled',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing FailedDestinationListUpdate',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming FailedDestinationListUpdate',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InjectedIcmp',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InjectedIcmp',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing StormLimit',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming StormLimit',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Wnv',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Wnv',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidFirstNBTooSmall',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidFirstNBTooSmall',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidSourceMac',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidSourceMac',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidDestMac',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidDestMac',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidVlanFormat',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidVlanFormat',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing NativeFwdingReq',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming NativeFwdingReq',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing MTUMismatch',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming MTUMismatch',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidConfig',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidConfig',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing RequiredExtensionMissing',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming RequiredExtensionMissing',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing VirtualSubnetId',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming VirtualSubnetId',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing BridgeReserved',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming BridgeReserved',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing RouterGuard',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming RouterGuard',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing DhcpGuard',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming DhcpGuard',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing MacSpoofing',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming MacSpoofing',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Ipsec',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Ipsec',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Qos',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Qos',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing FailedPvlanSetting',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming FailedPvlanSetting',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing FailedSecurityPolicy',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming FailedSecurityPolicy',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing UnauthorizedMAC',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming UnauthorizedMAC',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing UnauthorizedVLAN',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming UnauthorizedVLAN',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing FilteredVLAN',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming FilteredVLAN',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Filtered',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Filtered',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Busy',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Busy',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing NotAccepted',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming NotAccepted',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Disconnected',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Disconnected',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing NotReady',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming NotReady',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Resources',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Resources',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidPacket',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidPacket',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing InvalidData',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming InvalidData',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Outgoing Unknown',
'\\Hyper-V Virtual Network Adapter Drop Reasons({0}_Network Adapter_{1}--{2})\\Incoming Unknown'
)
$SaveSnapChecks = @( # same for 2012R2 and 2016
'\\Hyper-V VM Save, Snapshot, and Restore({0}:Current or most recent Save-Restore-Snapshot operation)\\Operation Time',
'\\Hyper-V VM Save, Snapshot, and Restore({0}:Current or most recent Save-Restore-Snapshot operation)\\Requests High Priority',
'\\Hyper-V VM Save, Snapshot, and Restore({0}:Current or most recent Save-Restore-Snapshot operation)\\Requests Processed',
'\\Hyper-V VM Save, Snapshot, and Restore({0}:Current or most recent Save-Restore-Snapshot operation)\\Requests Dispatched',
'\\Hyper-V VM Save, Snapshot, and Restore({0}:Current or most recent Save-Restore-Snapshot operation)\\Requests Active',
'\\Hyper-V VM Save, Snapshot, and Restore({0}:Current or most recent Save-Restore-Snapshot operation)\\Threads Spawned'
)
$SmartPagingChecks = @( # same for 2012R2 and 2016
'\\Hyper-V Dynamic Memory VM({0})\\Smart Paging Working Set Size'
)
$VidChecks = @( # same for 2012R2 and 2016
'\\Hyper-V VM Vid Partition({0})\\Remote Physical Pages',
'\\Hyper-V VM Vid Partition({0})\\Preferred NUMA Node Index',
'\\Hyper-V VM Vid Partition({0})\\Physical Pages Allocated'
)
#$VirtualDevicePipeChecks = @( # 2016 only -- uncertain where the GUIDs in {2}
# '\\Hyper-V VM Virtual Device Pipe IO({0}:{1}-{{{2}}})\\Receive Message Quota Exceeded',
# '\\Hyper-V VM Virtual Device Pipe IO({0}:{1}-{{{2}}})\\Receive QoS - Total Message Delay Time (100ns)',
# '\\Hyper-V VM Virtual Device Pipe IO({0}:{1}-{{{2}}})\\Receive QoS - Exempt Messages/sec',
# '\\Hyper-V VM Virtual Device Pipe IO({0}:{1}-{{{2}}})\\Receive QoS - Non-Conformant Messages/sec',
# '\\Hyper-V VM Virtual Device Pipe IO({0}:{1}-{{{2}}})\\Receive QoS - Conformant Messages/sec'
#)
#$VMBusProviderChecks = @( # 2016 only -- uncertain where the GUIDs in {2}
# '\\Hyper-V Virtual Machine Bus Provider Pipes({0}:{1}-{{{2}}})\\Bytes Written/sec',
# '\\Hyper-V Virtual Machine Bus Provider Pipes({0}:{1}-{{{2}}})\\Bytes Read/sec',
# '\\Hyper-V Virtual Machine Bus Provider Pipes({0}:{1}-{{{2}}})\\Writes/sec',
# '\\Hyper-V Virtual Machine Bus Provider Pipes({0}:{1}-{{{2}}})\\Reads/sec'
#)
$VMWorkerProcessChecks = @( # 2016 only
'\\Hyper-V Worker Virtual Processor({0}:WP VP {1})\\Intercepts Delayed',
'\\Hyper-V Worker Virtual Processor({0}:WP VP {1})\\Intercept Delay Time (ms)'
)
$VRSSChecks = @( # 2016 only
'\\Hyper-V Virtual Network Adapter VRSS({0}_Network Adapter_Entry _{1}_{2}--{3})\\SendPacketCompletionsPerSecond',
'\\Hyper-V Virtual Network Adapter VRSS({0}_Network Adapter_Entry _{1}_{2}--{3})\\SendPacketPerSecond',
'\\Hyper-V Virtual Network Adapter VRSS({0}_Network Adapter_Entry _{1}_{2}--{3})\\ReceivePacketPerSecond',
'\\Hyper-V Virtual Network Adapter VRSS({0}_Network Adapter_Entry _{1}_{2}--{3})\\SendProcessor',
'\\Hyper-V Virtual Network Adapter VRSS({0}_Network Adapter_Entry _{1}_{2}--{3})\\ReceiveProcessor'
)
$RemotingChecks = @( # 2016 only
'\\Hyper-V VM Remoting({0}:Remoting)\\Updated Pixels/sec',
'\\Hyper-V VM Remoting({0}:Remoting)\\Connected Clients'
)
}
process
{
Write-Progress -Activity 'Processing Input' -Status 'Processing Input'
$RawVMList = New-Object -TypeName System.Collections.ArrayList
if ($VM)
{
$InputType = $VM[0].GetType().FullName
if ($InputType -eq 'Microsoft.HyperV.PowerShell.VirtualMachine')
{
foreach ($VMObject in $VM)
{
$OutNull = $RawVMList.Add((Get-CimInstance -ComputerName $VMObject.ComputerName -Namespace 'root/virtualization/v2' -ClassName 'Msvm_ComputerSystem' -Filter ('Name="{0}"' -f $VMObject.Id)))
}
}
elseif ($InputType -eq 'System.String')
{
foreach ($VMObject in $VM)
{
$OutNull = $RawVMList.Add((Get-CimInstance -ComputerName $ComputerName -Namespace 'root/virtualization/v2' -ClassName 'Msvm_ComputerSystem' -Filter ('ElementName="{0}"' -f $VMObject)))
}
}
elseif ($InputType -eq 'Microsoft.Management.Infrastructure.CimInstance' -and $VM[0].CreationClassName -eq 'Msvm_ComputerSystem')
{
$RawVMList.AddRange($VM)
}
elseif ($InputType -eq 'System.Management.ManagementObject')
{
foreach ($VMObject in $VM)
{
$OutNull = $RawVMList.Add((Get-CimInstance -ComputerName $VMObject.__SERVER -Namespace 'root/virtualization/v2' -ClassName 'Msvm_ComputerSystem' -Filter ('Name="{0}"' -f $VMObject.Name)))
}
}
else
{
throw('Unable to process VM objects of type {0}' -f $InputType)
}
}
else
{
$RawVMList.AddRange((Get-CimInstance -ComputerName $ComputerName -Namespace 'root/virtualization/v2' -ClassName 'Msvm_ComputerSystem'))
}
switch ($LineEndFormat[0].ToString().ToLower())
{
'l' { $LineEnding = "`n" }
'm' { $LineEnding = "`r" }
default { $LineEnding = "`r`n" }
}
Write-Progress -Activity 'Processing Input' -Status 'Loading Virtual Machines' -Completed
if (-not $RawVMList.Count)
{
Write-Debug -Message 'No VMs specified in this pass'
return
}
$SanitizedVMList = @($RawVMList | Where-Object -Property 'Name' -Match $GUIDPattern)
if ($SanitizedVMList)
{
$VMList.AddRange($SanitizedVMList)
}
else
{
Write-Debug -Message 'A Hyper-V host was specified, but no VMs were found. Verify your permissions.'
return
}
$VMList = Sort-Object -InputObject $VMList -Property 'ElementName'
}
end
{
if (-not $VMList.Count)
{
Write-Warning -Message 'No VMs found'
return
}
$PercentTracker = 0
$ProcessPercentagePerVM = 100 * (1 / $VMList.Count)
Write-Progress -Activity 'Retrieving Virtual Machine Information' -Status 'Loading List' -PercentComplete $PercentTracker
foreach ($TargetVM in $VMList)
{
$PercentTracker += $ProcessPercentagePerVM
Write-Progress -Activity 'Retrieving Virtual Machine Information' -Status $TargetVM.ElementName -PercentComplete $PercentTracker
$HostName = $TargetVM.ComputerName
try
{
$VMSD = Get-CimAssociatedInstance -InputObject $TargetVM -ResultClassName 'Msvm_VirtualSystemSettingData' | Where-Object -Property 'VirtualSystemType' -EQ -Value 'Microsoft:Hyper-V:System:Realized'
$VMCPUData = Get-CimAssociatedInstance -InputObject $VMSD -ResultClassName 'Msvm_ProcessorSettingData'
$VMDisks = Get-CimAssociatedInstance -InputObject $VMSD -ResultClassName 'Msvm_StorageAllocationSettingData' | where ResourceSubType -EQ 'Microsoft:Hyper-V:Virtual Hard Disk'
$VMMemory = (Get-CimAssociatedInstance -InputObject $VMSD -ResultClassName 'Msvm_MemorySettingData')[0]
$VMIsClustered = [bool](
[bool]((Get-CimAssociatedInstance -InputObject $VMSD -ResultClassName 'Msvm_KvpExchangeComponentSettingData').HostOnlyItems) -and
(Get-CimAssociatedInstance -InputObject $VMSD -ResultClassName 'Msvm_KvpExchangeComponentSettingData').HostOnlyItems[0].Contains('VirtualMachineIsClustered')
)
$HostName = (Get-CimAssociatedInstance -InputObject $TargetVM -ResultClassName 'Msvm_VirtualSystemManagementService').SystemName
$Version = '2012R2'
$DetectedVersion = (Get-CimInstance -ComputerName $HostName -ClassName 'Win32_OperatingSystem').Version
if ($DetectedVersion -match '^10\.') { $Version = '2016' }
$VMMigrationSettings = Get-CimInstance -ComputerName $HostName -Namespace root/virtualization/v2 -ClassName Msvm_VirtualSystemMigrationServiceSettingData
if ($VMIsClustered)
{
$HostName = (Get-CimInstance -ComputerName $HostName -Namespace 'root/MSCluster' -ClassName 'MSCluster_Cluster').Name
}
}
catch
{
Write-Warning -Message ('An error occurred while retrieving data for {0}' -f $TargetVM.ElementName)
Write-Error $_
continue
}
if ($ResolveHost)
{
try
{
$HostName = (Resolve-DnsName -Name $HostName).IPAddress
}
catch
{
Write-Warning -Message ('Cannot resolve {0} to an IP address. Using "{0}" for the generated service target' -f $HostName)
}
}
elseif ($UpperCaseHostName)
{
$HostName = $HostName.ToUpper()
}
$ServiceObjectParameters =
@{
'HostName' = $HostName;
'VMName' = $TargetVM.ElementName;
'Clustered' = $VMIsClustered;
}
$VMNetAdapters = Get-CimAssociatedInstance -InputObject $TargetVM -ResultClassName 'Msvm_SyntheticEthernetPort'
if ($IncludeAdvancedCounters)
{
$ChecksList = $AdvancedChecks
if ($Version -eq '2016') { $ChecksList += $AdvancedChecks2016 }
foreach ($AdvancedCounter in $AdvancedChecks)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory 'VM' -Counter ($AdvancedCounter -f $TargetVM.ElementName)))
}
}
if (-not $SkipCPU)
{
$ChecksList = $CPUCoreChecks
if ($IncludeAdvancedCounters)
{
$ChecksList += $CPUAdvancedChecks
if ($Version -eq '2016') { $ChecksList += $CPUAdvanced2016Checks }
}
if ($Version -eq '2016' -and $IncludeVmWorkerProcess) { $ChecksList += $VMWorkerProcessChecks }
for ($i = 0; $i -lt $VMCPUData.VirtualQuantity; $i++)
{
foreach ($CPUCounter in $ChecksList)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory ([String]::Join(' ', 'vCPU', $i)) -Counter ($CPUCounter -f $TargetVM.ElementName, $i)))
}
}
}
if (-not $SkipDisk)
{
foreach ($VMDisk in $VMDisks)
{
$ChecksList = $DiskCoreChecks
if ($IncludeAdvancedCounters) { $ChecksList += $DiskAdvancedChecks }
if ($IncludeAdvancedCounters -and $Version -eq '2012R2') { $ChecksList += $DiskAdvanced2012R2Checks }
if ($IncludeAdvancedCounters -and $Version -eq '2016') { $ChecksList += $DiskAdvanced2016Checks }
$DiskName = $VMDisk.HostResource[0]
$DiskCounterPath = $DiskName -replace '^\\\\', '--?-UNC-'
$DiskCounterPath = $DiskCounterPath -replace '\\', '-'
$CounterCategory = [String]::Join(' ', 'vDisk', $DiskName.Substring($DiskName.LastIndexOf('\') + 1))
foreach ($DiskCounter in $DiskCoreChecks)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory $CounterCategory -Counter ($DiskCounter -f $DiskCounterPath)))
}
}
}
if (-not $SkipDynamicMemory)
{
$ChecksList = @()
if ($Version -eq '2016' -or $VMMemory.DynamicMemoryEnabled) { $ChecksList += $DynamicMemoryChecks }
if ($VMMemory.DynamicMemoryEnabled) { $ChecksList += $DynamicMemoryDMOnlyChecks }
if ($Version -eq '2016' -and $VMMemory.DynamicMemoryEnabled) { $ChecksList += $DynamicMemoryChecks2016 }
foreach ($DynamicMemoryCounter in $ChecksList)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory 'vMemory' -Counter ($DynamicMemoryCounter -f $TargetVM.ElementName)))
}
}
if ($VMIsClustered -and $IncludeLiveMigration)
{
$ChecksList = $LiveMigrationChecks
if ($VMMigrationSettings.EnableCompression) { $ChecksList += $LiveMigrationCompressionChecks }
if ($VMMigrationSettings.EnableSmbTransport) { $ChecksList += $LiveMigrationSMBChecks }
foreach ($LiveMigrationCounter in $LiveMigrationChecks)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory 'Live Migration' -Counter ($LiveMigrationCounter -f $TargetVM.ElementName)))
}
}
if ($VMSD.VirtualSystemSubType -eq 'Microsoft:Hyper-V:SubType:1' -and $IncludeIDE)
{
foreach ($IDECount in $IDEChecks)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory 'vIDE' -Counter ($IDECount -f $TargetVM.ElementName)))
}
}
if ($VMNetAdapters -and -not $SkipNetwork)
{
foreach ($VMNetAdapter in $VMNetAdapters)
{
$FoundAdapterIDs = $false
if ($VMNetAdapter.DeviceId -match $GUIDPattern)
{
$DeviceID = $Matches[0].ToLower()
$FoundAdapterIDs = $true
}
if ($FoundAdapterIDs -and $VMNetAdapter.SystemName -match $GUIDPattern)
{
$SystemName = $Matches[0].ToLower()
$FoundAdapterIDs = $true
}
if ($FoundAdapterIDs)
{
$ChecksList = $NetworkCoreChecks
if ($IncludeAdvancedCounters) { $ChecksList += $NetworkAdvancedChecks }
if ($Version -eq '2016' -and $IncludeNetworkDropReasons) { $ChecksList += $NetworkDropReasonChecks }
foreach ($NetworkCounter in $ChecksList)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory 'vNIC' -Counter ($NetworkCounter -f $TargetVM.ElementName, $SystemName, $DeviceID)))
}
if ($Version -eq '2016' -and $IncludeVRSS)
{
foreach ($VP in @(0..15))
{
foreach ($VRSSCheck in $VRSSChecks)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory ('vRSS VP {0}' -f $VP) -Counter ($VRSSCheck -f $TargetVM.ElementName, $VP, $SystemName, $DeviceID)))
}
}
}
}
}
}
if ($IncludeSavesSnaps)
{
foreach ($SaveSnapCounter in $SaveSnapChecks)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory 'Save and Snapshot' -Counter ($SaveSnapCounter -f $TargetVM.ElementName)))
}
}
if ($IncludeSmartPaging)
{
foreach ($SmartPagingCounter in $SmartPagingChecks)
{
$OutNull = $CounterList.Add((New-ServiceObject @ServiceObjectParameters -CounterCategory 'Smart Paging' -Counter ($SmartPagingCounter -f $TargetVM.ElementName)))
}
}
if ($IncludeNUMA)
{
foreach ($VidCounter in $VidChecks)