Diag-V – A Hyper-V Diagnostic Utility

Introducing Diag-V, a Powershell Hyper-V Diagnostic Utility

Diag-V is a PowerShell based script that contains a collection of various Hyper-V diagnostics. It presents the user a simple choice menu that allows the user to select and execute the desired diagnostic.

Where can I download Diag-V?

Download Diag-V from Technet via the link below:

https://gallery.technet.microsoft.com/scriptcenter/Diag-V-A-Hyper-V-0fe983e4

I want to contribute to Diag-V

Great! If you find a bug or think a diagnostic should be added you can see the code and contribute via Git at the link below:

https://github.com/techthoughts2/Diag-V

How do I use Diag-V?

Take a look at this short video demo or visit the technet/git links above for a detailed how-to breakdown.

Diag-V - A Hyper-V Diagnostic - Main Menu
Diag-V Main Menu

What diagnostics can Diag-V perform?

This is likely to change as Diag-V is enhanced and improved.  See below for a current breakdown of all available diagnostics and their capabilities:

Get-VMStatus

<#
.Synopsis
    Name, State, CPUUsage, Memory usage, Uptime, and Status of all VMs on a 
    cluster or standalone hyp
.DESCRIPTION
    Gets the status of all discovered VMs. Automatically detects if running on a 
    standalone hyp or hyp cluster. If standalone is detected it will display VM 
    status information for all VMs on the hyp. If a cluster is detected it will 
    display VM status information for each node in the cluster.
.EXAMPLE
    Get-VMStatus

    This command will automatically detect a standalone hyp or hyp cluster and 
    will retrieve VM status information for all detected nodes.
.OUTPUTS
    Cluster detected. Executing cluster appropriate diagnostic...
    ----------------------------------------------
    RUNNING VMs
    ----------------------------------------------
    HypV1
    No VMs are present on this node.
    ----------------------------------------------
    Hypv2
    There are no running VMs - probably not a good thing. Fix it.
    ----------------------------------------------


    ----------------------------------------------
    NOT RUNNING VMs
    ----------------------------------------------
    HypV1
    No VMs are present on this node.
    ----------------------------------------------
    Hypv2

    Name         State CPUUsage(%) MemoryAssigned(M) Uptime   Status            
    ----         ----- ----------- ----------------- ------   ------            
    2008R2Clust  Off   0           0                 00:00:00 Operating normally
    2008R2Clust2 Off   0           0                 00:00:00 Operating normally
    2012R2Clust  Off   0           0                 00:00:00 Operating normally
    2012R2Clust2 Off   0           0                 00:00:00 Operating normally
    Web1         Off   0           0                 00:00:00 Operating normally
    ----------------------------------------------
.NOTES
    Author: Jake Morrison
    TechThoughts - http://techthoughts.info
.FUNCTIONALITY
     Get the following VM information for all detected Hyp nodes:
     Name
     State
     CPUUsage
     Memory
     Uptime
     Status
#>

Get-VMLocationPathInfo

<#
.Synopsis
    A VM is comprised of multiple components. Each can reside in a different 
    location. This script will identify the location of all of those components
.DESCRIPTION
    A VM is comprised of a few components besides just .vhd/.vhdx. This will 
    retrieve the location paths for the VM's configuration files, Snapshot Files, 
    and Smart Paging files. If on a standalone it will display this information 
    for all VMs on the standalone hyp. If a cluster is detected it will display
    this information for all VMs found on each node.
.EXAMPLE
    Get-VMLocationPathInfo

    This command will display the file paths for all VM components.
.OUTPUTS
    Cluster detected. Executing cluster appropriate diagnostic...
    ----------------------------------------------
    HypV1
    No VMs are present on this node.
    ----------------------------------------------
    Hypv2


    VMName                : 2008R2Clust
    ComputerName          : Hypv2
    State                 : Off
    Path                  : \\sofs-csv\VMs\2008R2Clust
    ConfigurationLocation : \\sofs-csv\VMs\2008R2Clust
    SnapshotFileLocation  : \\sofs-csv\VMs\2008R2Clust
    SmartPagingFilePath   : \\sofs-csv\VMs\2008R2Clust
    ----------------------------------------------
.NOTES
    Author: Jake Morrison
    TechThoughts - http://techthoughts.info
.FUNCTIONALITY
     Get the following VM information for all detected Hyp nodes:
     VMName
     ComputerName
     State
     ConfigurationLocation
     SnapshotFileLocation
     SmartPagingFilePath
#>

Get-IntegrationServicesCheck

<#
.Synopsis
    Displays IntegrationServicesVersion and enabled integration services for all VMs 
.DESCRIPTION
    Gets the IntegrationServicesVersion and enabled integration services for all VMs.
    Automatically detects if running on a standalone hyp or hyp cluster. 
    If standalone is detected it will display VM integration services information 
    for all VMs on the hyp. If a cluster is detected it will display VM integration 
    services information for all VMs found on each node.
.EXAMPLE
    Get-IntegrationServicesCheck

    This command displays integration services information for all discovered VMs.
.OUTPUTS
    Standalone server detected. Executing standalone diagnostic...
    ----------------------------------------------
    LinuxTest - no integration services installed
    ----------------------------------------------
    LinuxTest3 - no integration services installed
    ----------------------------------------------
    LinuxTest4 - no integration services installed
    ----------------------------------------------
    PDC2 - version: 6.3.9600.16384

    Name                    Enabled
    ----                    -------
    Time Synchronization       True
    Heartbeat                  True
    Key-Value Pair Exchange    True
    Shutdown                   True
    VSS                        True
    Guest Service Interface   False
    ----------------------------------------------
    TestLinux2 - no integration services installed
    ----------------------------------------------
.NOTES
    Author: Jake Morrison
    TechThoughts - http://techthoughts.info
.FUNCTIONALITY
     Get the following VM information for all detected Hyp nodes:
     IntegrationServicesVersion
     Enabled status for all integration services
#>

Get-VMAllVHDs

<#
.Synopsis
    For each VM detected every associated VHD/VHDX is identified and several pieces of 
    VHD/VHDX information is displayed
.DESCRIPTION
    Identifies all VHDs/VHDXs associated with each VM detected. For each VHD/VHDX it
    pulls several pieces of information and displays to user. It then
    sums the current VHD/VHDX disk usage and the POTENTIAL VHD/VHDX disk usage
    dependent on whether the VHDs/VHDXs are fixed are dynamic.
.EXAMPLE
    Get-VMAllVHDs

    Displays information for each VHD for every VM discovered
.OUTPUTS
    Standalone server detected. Executing standalone diagnostic...
    ----------------------------------------------
    2008R2Clust2

    VhdType Size(GB) MaxSize(GB) Path                                                            
    ------- -------- ----------- ----                                                            
    Dynamic       14          60 \\sofs-csv\VMs\2008R2Clust2\Virtual Hard Disks\2008R2Clust2.vhdx
    ----------------------------------------------
    Web1

    VhdType Size(GB) MaxSize(GB) Path                                            
    ------- -------- ----------- ----                                            
    Dynamic       12          40 \\sofs-csv\VMs\Web1\Virtual Hard Disks\Web1.vhdx
    ----------------------------------------------
    VMs are currently utilizing:  48 GB
    VMs could POTENTIALLY Utilize:  180 GB
    ----------------------------------------------
.NOTES
    Author: Jake Morrison
    TechThoughts - http://techthoughts.info
.FUNCTIONALITY
     Get the following VM VHD information for all detected Hyp nodes:
     VhdType
     Size(GB)
     MaxSize(GB)
     Path
     Total current disk usage
     Total POTENTIAL disk usage
#>

Get-SharedVHDs

<#
.Synopsis
    For each VM detected every associated VHD/VHDX is identified and several pieces of 
    VHD/VHDX information is displayed
.DESCRIPTION
    Identifies all VHDs/VHDXs associated with each VM detected. For each VHD/VHDX it
    pulls several pieces of information to display to user. If 
    SupportPersistentReservations is true, the VHD/VHDX is shared.
.EXAMPLE
    Get-SharedVHDs

    Displays SupportPersistentReservations information for each VHD for every VM 
    discovered. If SupportPersistentReservations is true, the VHD is shared
.OUTPUTS
    Standalone server detected. Executing standalone diagnostic...
    ----------------------------------------------
    2008R2Clust2

    VhdType Size(GB) MaxSize(GB) Path                                                            
    ------- -------- ----------- ----                                                            
    Dynamic       14          60 \\sofs-csv\VMs\2008R2Clust2\Virtual Hard Disks\2008R2Clust2.vhdx
    ----------------------------------------------
    Web1

    VhdType Size(GB) MaxSize(GB) Path                                            
    ------- -------- ----------- ----                                            
    Dynamic       12          40 \\sofs-csv\VMs\Web1\Virtual Hard Disks\Web1.vhdx
    ----------------------------------------------
    VMs are currently utilizing:  48 GB
    VMs could POTENTIALLY Utilize:  180 GB
    ----------------------------------------------
.NOTES
    Author: Jake Morrison
    TechThoughts - http://techthoughts.info
.FUNCTIONALITY
     Get the following VM VHD information for all detected Hyp nodes:
     VMName
     SupportPersistentReservations
     Path
#>

Test-HyperVAllocation

<#
.Synopsis
    Determines the current resource allocation health of Hyper-V Server or Hyper-V Cluster
.DESCRIPTION
    For single Hyper-V instances this function will pull available
    CPU and Memory physical resources. It will then tally all VM CPU and memory
    allocations and contrast that info with available physical resources

    A cpu ratio higher than 4:1 (vCPU:Logical Processors) will be flagged as bad
    A static memory higher than 1:1 will be flagged as bad
    There is no best practice published around dynamic maximum memory so the function
    will only advise a warning if max memory is higher than available physical memory.

    The same functionality is supported for clustered Hyper-V instances.
    The function will poll each node in the cluster and provide info on each node.
    The cluster function will also calculate the simulation loss of one node to determine
    if VMs could survive and start with one node down.

    Available storage space will also be calculated. For clusters CSV locations will be
    checked. For standalone Hyps any drive larger than 10GB and not C: will be checked.
    In keeping with best practices anything with less than 20% free space will fail the
    health check.
.EXAMPLE
    Test-HyperVAllocation

    If executed on a standalone Hyper-V instance it will retrieve CPU/RAM physical resources
    If exectured on a Hyper-V cluster it will retrieve CPU/RAM physical resrouces for
    all nodes in the cluster and comapares those available resources to resources assigned
    to VMs on each Hyper-V instance.
.OUTPUTS
    -----------------------------
    SystemName: 80167-hyp2
    -----------------------------
    Cores: 24
    Logical Processors: 48
    Total Memory: 256 GB
    Free Memory: 248 GB
    Number of VMs: 1
    Number of VM Procs: 2
    -----------------------------
    Memory resources are still available:             97 % free
    -----------------------------
    Virtual Processors are not overprovisioned        1 : 1
    -----------------------------
    Total Startup memory required for Dynamic VMs:    0 GB 
    Total Static memory required for Static VMs:      29 GB 
    -----------------------------
    Total minimum RAM (Startup+Static) required:      29 GB 
    Minimum RAM: 29 GB does not exceed available RAM: 256 GB
    -----------------------------
    VMs would survive a one node failure
    Total VM RAM minumum: 56 GB - Total Cluster RAM available with one node down: 256 GB
    -----------------------------
    Storage Allocation Information
    -----------------------------
    C:\ClusterStorage\Volume2 has the recommended 20% free space.
    Free Space: 100 GB
    Percent Free: 99.87756
    -----------------------------
.NOTES
    Author: Jake Morrison
    TechThoughts - http://techthoughts.info
    You can change the CPU ratio cutoff from 4:1 to say 6:1 or 8:1 by editing the
    Highlighted section below to suit your requirements
.FUNCTIONALITY
     Get the following information for each Hyper-V instance found
     System Name
     Logical Processors
     Total Memory
     Free Memory
     Number of VMs
     Number of VM Procs
     CPU provisioning status
     Memory provisioning status
     Free space status
#>

Get-CSVtoPhysicalDiskMapping

<#
.Synopsis
    Resolves CSV to a physicalDisk drive
.DESCRIPTION
    Discovers all cluster shared volumes associated with the specificed cluster
    Resolves all cluster shared volumes to physical drives and pulls usefull
    information about the characteristcs of the associated physical drive
.EXAMPLE
    Get-CSVtoPhysicalDiskMapping

    This command retrieves all cluster shared volumes and pulls information 
    related to the physical disk associated with each CSV.  Since no cluster name 
    is specified this command resolves to a locally available cluster (".")
.EXAMPLE
    Get-CSVtoPhysicalDiskMappying -clusterName "Clus1.domain.local"

    This command retrieves all cluster shared volumes and pulls information related 
    to the physical disk associated with the CSVs that are associated with the 
    Clus1.domain.local cluster.
.OUTPUTS
    #CSVName : Cluster Disk 1
    #CSVPartitionNumber : 2
    #Size (GB) : 1500
    #CSVOwnerNode : node1
    #FreeSpace (GB) : 697
    #CSVVolumePath : C:\ClusterStorage\Volume1
    #CSVPhysicalDiskNumber : 3
    #Perecent Free : 46.49729
.NOTES
    Adapted from code written by Ravikanth Chaganti http://www.ravichaganti.com
    Enhanced by: Jake Morrison - TechThoughts - http://techthoughts.info
.FUNCTIONALITY
     Get the following information for each CSV in the cluster:
     CSV Name
     Total Size of associated physical disk
     CSV Volume Path
     Percent free of physical disk - VERY useful
     CSV Owner Node
     CSV Partition Number
     Freespace in (GB)
#>

Get-FileSizes

<#
.Synopsis
    Scans specified path and gets total size as well as top 10 largest files
.DESCRIPTION
    Recursively scans all files in the specified path. It then gives a total
    size in GB for all files found under the specified location as well as
    the top 10 largest files discovered. The length of scan completion is
    impacted by the size of the path specified as well as the number of files
.EXAMPLE
    Get-FileSizes -path C:\temp

    This command recursively scans the specified path and will tally the total
    size of all discovered files as well as the top 10 largest files.
.OUTPUTS
    Scan results for: c:\
    ----------------------------------------------
    Total size of all files: 175 GB.
    ----------------------------------------------
    Top 10 Largest Files found:

    Directory                                                         Name                                                Length
    ---------                                                         ----                                                ------
    C:\rs-pkgs                                                        ManagementPC.vhdx                                    28.19
    C:\rs-pkgs                                                        CentOS-7-x86_64-Everything-1503-01.iso                7.07
    C:\                                                               hiberfil.sys                                          6.38
    C:\rs-pkgs                                                        en_windows_10_multiple_editions_x64_dvd_6846432.iso    3.8
    C:\rs-pkgs                                                        UbuntuServer14.vhdx                                    3.6
    C:\GOG Games\The Witcher 3 Wild Hunt\content\content0             texture.cache                                         3.24
    C:\GOG Games\The Witcher 3 Wild Hunt\content\content4\bundles     movies.bundle                                         3.23
    C:\Program Files (x86)\StarCraft II\Campaigns\Liberty.SC2Campaign Base.SC2Assets                                        3.16
    C:\Program Files (x86)\StarCraft II\Mods\Liberty.SC2Mod           Base.SC2Assets                                        2.42
    C:\                                                               pagefile.sys                                          2.38
    ----------------------------------------------
.NOTES
    Author: Jake Morrison - TechThoughts - http://techthoughts.info
.FUNCTIONALITY
     Get the following information for the specified path:
     Total size of all files found under the path
     Top 10 largest files discovered
#>

Be the first to comment

Leave a Reply

Your email address will not be published.


*