Get PVS Target Device Retries

Gets the PVS target device retries count via the "Mcli-Get DeviceStatus" PowerShell command. This action should be executed on a PVS server with the MCLI PowerShell snap-in installed.
Version 1.2.4
Created on 2015-08-09
Modified on 2015-08-10
Created by Yoni Avital
Downloads: 572

The Script Copy Script Copied to clipboard
$devicename = $args[0].Split(".")[0]

$ErrorActionPreference = "Stop"

If ( (Get-PSSnapin -Name McliPSSnapIn -ErrorAction SilentlyContinue) -eq $null )
{
    Try {
        Import-Module "$env:programfiles\Citrix\Provisioning Services Console\McliPSSnapIn.dll"  -WarningAction SilentlyContinue
    } Catch {
        Write-Host "There is a problem loading the Powershell SnapIn. It is not possible to continue."
        Exit 1
    }
}

Try {
    Mcli-help | Out-Null
}
Catch {
    Write-Host "This is not a PVS server. Exiting."
    Exit 1
}

Try {
    $retrycount = (mcli-get devicestatus -p devicename=$devicename -f status | select-string "status:").line.split(":")[1].trim()
}
Catch {
    Write-Host "This is not a PVS target device."
    Exit 1
}

Write-Host "Target Device Retries = $retrycount"