#Requires -Version 3.0
#This File is in Unicode format.  Do not edit in an ASCII editor.
$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
$PSDefaultParameterValues = @{'*:Encoding' = 'utf8'}

#region help text

<#
.SYNOPSIS
	Creates an inventory of a Citrix PVS Available check details.
.DESCRIPTION
	Creates an inventory of a Citrix PVS Available check details using Microsoft PowerShell.
	
	The PVS Console must be installed and the snap-in registered on the computer running 
	the script.
	
	For Windows 8.x, Server 2012 and later, run:
	
	For 32-bit:
	%systemroot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe "%ProgramFiles%\Citrix\Provisioning Services Console\Citrix.PVS.SnapIn.dll"
	
	For 64-bit:
	%systemroot%\Microsoft.NET\Framework64\v4.0.30319\installutil.exe "%ProgramFiles%\Citrix\Provisioning Services Console\Citrix.PVS.SnapIn.dll"
	
	
.INPUTS
	None.  You cannot pipe objects to this script.
.OUTPUTS
	No objects are output from this script.  
.NOTES
    Test	: PVSAvailCheckTest
	
	Measures:
		1. Availability (%)
	    2. Response time (Secs)
#>

#endregion

#region initialize variables
$SaveEAPreference = $ErrorActionPreference
$ErrorActionPreference = 'SilentlyContinue'
$global:isErrorOccured = $False  

$global:CONST_SCRIPT_START = "***Start_Citrix_PVS_server_config_data_***";
$global:CONST_SCRIPT_END = "***End_Citrix_PVS_server_config_data_***";
$global:CONST_DELIMITER = "~#~";

Add-PSSnapin Citrix.PVS.SnapIn

#endregion


Function getPVSAvailCheckDetails
{
    try
    {
        $StarTicks = (Get-Date).Ticks
        $pvsFarm =  Get-PvsFarm -fields FarmName
        $EndTicks = (Get-Date).Ticks
        $DiffTicks = ($EndTicks - $StarTicks) / 10000.0 # Convert Ticks to Millis
        
        If($? -and $pvsFarm -ne $Null)
        {
            Write-Host $($CONST_SCRIPT_START)
            Write-Host "FarmName: $($pvsFarm.FarmName)"  "#"  $DiffTicks
        }
    }
    catch
    {
	    $global:isErrorOccured = $True
	    Write-Host " PVSAvailCheckTest powershell script Exception ";
        Write-Host $_
    }

    If(-Not $isErrorOccured)
    {
	    Write-Host $CONST_SCRIPT_END
    }
}

getPVSAvailCheckDetails
Remove-PSSnapin Citrix.PVS.SnapIn