PowerShell Function to Determine the Installed VSS Providers

I’ve been migrating one of my customers from some older EqualLogic storage area networks to a Nimble SAN. It has all been good with the exception of some problems with VSS (Volume Shadow Copy Service). They use Altaro for backups and from what I’ve found, Nimble and Altaro don’t play well together when it comes to VSS. Nimble’s software was installed on the Hyper-V hosts and all three vendors (Nimble, EqualLogic, and Altaro) VSS providers seemed to play well together until volumes were actually moved to the Nimble SAN. The backup for each and every VM failed consistently once they were onto the Nimble SAN.

Once the Nimble VSS provider was removed from the Hyper-V hosts, all was well again with the Altaro backups. With all of this drama about VSS problems, I was surprised to find that there aren’t any PowerShell cmdlets for working with VSS so I decided to write a function that could at least be used to determine what VSS providers exist on a computer without having to dig around in the registry manually.

#Requires -Version 3.0
function Get-MrVssProvider {

<#
.SYNOPSIS
    Retrieves a list of the VSS providers that are installed on the specified computer(s).

.DESCRIPTION
    Get-MrVssProvider is an advanced function for determining what VSS (Volume Shadow Copy Service) providers are
    currently installed on one or more computers.

.PARAMETER ComputerName
    The name of the computer(s) to determine the VSS providers for.

.PARAMETER Credential
    Specifies a user account that has permission to perform this action. The default is the current user.

    Type a user name, such as User01 or Domain01\User01. Or, enter a PSCredential object, such as one generated by the
    Get-Credential cmdlet. If you type a user name, this cmdlet prompts you for a password.

.EXAMPLE
     Get-MrVssProvider -ComputerName Server01, Server02, Server03

.EXAMPLE
     Get-MrVssProvider -ComputerName Server01, Server02, Server03 -Credential (Get-Credential)

.INPUTS
    None

.OUTPUTS
    PSCustomObject

.NOTES
    Author:  Mike F Robbins
    Website: http://mikefrobbins.com
    Twitter: @mikefrobbins
#>

    [CmdletBinding()]
    param (
        [ValidateNotNullOrEmpty()]
        [string[]]$ComputerName = $env:COMPUTERNAME,

        [System.Management.Automation.Credential()]$Credential = [System.Management.Automation.PSCredential]::Empty
    )

    $Params = @{
        ComputerName = $ComputerName
        ScriptBlock = {Get-ChildItem -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\VSS\Providers' |
                       Get-ItemProperty -Name '(default)'}
        ErrorAction = 'SilentlyContinue'
        ErrorVariable = 'Problem'
    }

    if ($PSBoundParameters.Credential) {
        $Params.Credential = $Credential
    }

    Invoke-Command @Params |
    Select-Object -Property PSComputerName, @{label='VSSProviderName';expression={$_.'(default)'}}

    foreach ($p in $Problem) {
        if ($p.origininfo.pscomputername) {
            Write-Warning -Message "Unable to read registry key on $($p.origininfo.pscomputername)"
        }
        elseif ($p.targetobject) {
            Write-Warning -Message "Unable to connect to $($p.targetobject)"
        }
    }

}

Simply call the function, specify the server names, and credentials. If credentials aren’t specified, the currently logged on users credentials are used.

Get-MrVssProvider -ComputerName dc01, doesnotexist, sql02

vss-provider1a.jpg

PowerShell remoting does need to be enabled on the targeted systems, but that shouldn’t be a problem for most since PowerShell remoting is enabled by default on Windows Server 2012 and higher and it can be enabled on others with the Enable-PSRemoting cmdlet as long as PowerShell version 2.0 or higher is installed.

The Get-MrVssProvider function shown in this blog article can be downloaded from my PowerShell repository on GitHub.

ยต