New ‘ Test-SBVHDIntegrity’ function added to SBTools module tests VM VHD(x) files’ integrity


SBTools module can be downloaded from the Microsoft Script Center Repository.

To install it, extract the .rar file, and run install-SBTools.ps1 in the folder where you extracted the .rar file.

The Test-SBVHDIntegrity function will test the drive files of a Hyper-V virtual machine and verify the specified file exists and that there are no problems with it.

This is a function by Jeff Hicks originally published here, modified by Sam Boutros 08/09/2014, added functionality to work on VMs from other than localhost.

NAME
Test-SBVHDIntegrity

SYNOPSIS
Test VHD files for integrity

SYNTAX
Test-SBVHDIntegrity [-VM] <Object[]> [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION
Test the drive files for a Hyper-V virtual machine and verify the specified
file exists and that there are no problems with it.

PARAMETERS
-VM <Object[]>
VM object. Function will check integrity of input VM disk files.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false

-WhatIf [<SwitchParameter>]

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Confirm [<SwitchParameter>]

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

————————– EXAMPLE 1 ————————–

C:\PS>Get-VM | Test-SBVHDIntegrity | Out-Gridview

————————– EXAMPLE 2 ————————–

C:\PS>Get-VM -ComputerName xHost11,xHost12 | Test-SBVHDIntegrity | Out-Gridview

This example displays disk integrity results for each VM on the Hyper-V hosts xHost11 and xHost12

————————– EXAMPLE 3 ————————–

C:\PS>Get-VM -ComputerName (Get-Content .\computers.txt) | Test-SBVHDIntegrity | Out-Gridview

This example displays disk integrity results for each VM on the Hyper-V hosts listed n the .\computers.txt file

————————– EXAMPLE 4 ————————–

C:\PS>Get-VM | Test-SBVHDIntegrity | where {(-NOT $_.TestPath) -OR (-NOT $_.TestVHD)}

This examples displays disks that fail either the TestPath or TestVHD checks

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s