Global_7x_Citrix_XenApp_Health_Check_Dashboard.ps1


<#PSScriptInfo
 
.VERSION 1.0
 
.GUID 1ba878e9-0e96-4084-bc47-e8a9e1227dc0
 
.AUTHOR Mohammad Nadeem Siddiqui
 
.COMPANYNAME
 
.COPYRIGHT
 
.TAGS
    Citrix Xenapp 7x
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
     
    Citrix Module
 
.REQUIREDSCRIPTS
   
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
 
 
#>


<#
 
.DESCRIPTION
 This script provide the Health Check Report of the Citrix 7.x environment
  
 This Script need to be run on Delivery Controller with Citrix Admin Access
 
 
 Below are the parameters you will get in the Report
 
 *Broker Controller
Name
Number of VDA Register to DDC
Last Active Time of Broker Service
Last time contacted Licensing Server
Licensing Server State as per Broker Service
Status
 
*Delivery Controller Status
 
DeliveryController
Acc Serivice Status
Config Serivice Status
Admin Serivice Status
Broker Serivice Status
Log Serivice Status
Monitor Serivice Status
 
 
*Database Connection Status
 
Delivery Controller
Broker DB Connection
Monitor DB Connection
Log DB Connection
Account DB Connection
Admin DB Connection
 
*Licenses Status
 
License Server Name
License Server Port
Active Session
Peak Concurrent Connection Count
Module
Is There Any Grace Period
Is LocalHost Cache Enable
 
*ICA Port Status
 
Computer Name
Ping Status
ICA Port Number
ICA Port Status
 
*VDA Status
 
Server Name
IP
Session Count
Last Connection
Reporting to DDC
Is Maintenance Mode ON
Status
 
*Infra Status
Server Name
Last Boot Time
Total Ram
Free Ram
used RAM
Ram Percent Used
Avg. CPU Usage
PageFile
Allocated Base Size (MB)
PeakUsage (MB)
Current Usage (MB)
 
*Disk Space
 
Dive
Server Name
Size (GB)
Free (GB)
Free (%)
 
#>
 


###########################################################################

#Provide the path for Error Log File.

Write-Verbose "Getting the location for Error Log File"

[string]$ErrorLog = 'D:\ErrorLog.txt'

Write-Verbose "Completed getting location for Error Log File"

#Provide the path for Report file location.

Write-Verbose "Getting location to save Report"

#Note :- The Report Namme will be Filename+Month+Day+Year+Hour+Min+Sec

$Reportlocation = "D:\XenApp_Health_Check_Report_" # Please add UNDESCORE ("_") to the file Name

Write-Verbose "Completed Getting location to save Report"

##########################################################################


#==============================================================================================

# Warning : Don't change below here if you don't know what you are doing ...
#==============================================================================================

$VerbosePreference = 'Continue'


#Provide the path for the out-put HTML

#Write-Verbose "Getting location to save Report"


$filedate = (get-date).Month.ToString() + (Get-Date).Day.tostring() + (get-date).Year.tostring() + (get-date).hour.tostring() + (get-date).minute.tostring() + (get-date).Second.tostring()

$Report = $Reportlocation + "$filedate" + ".html"


#Write-Verbose "Completed Getting location to save Report"


##########################################################

# Below parament will check if the Citrix* Module is installed or not.
# If it isn't installed it will installed the Citrix Module.

Write-Verbose "Adding Citrix Module"


if ((Get-PSSnapin "Citrix*" -EA silentlycontinue) -eq $null) {
try { Add-PSSnapin Citrix* -ErrorAction Stop }
catch { write-error "Error Get-PSSnapin Citrix* Powershell snapin"; Return }
}

Write-Verbose "Completed Adding Citrix Module"

##########################################################




function Get-NSBrokercontroller {


<#
.Synopsis
   Using the Get-NSBrokercontroller will get the current status of Delivery Controllers
 
.DESCRIPTION
 
    This command provide details infoamtion about the Delivery Controllers
 
    It contain below information.
 
    1.Name
        This section contain Delivery Controllers Name
 
    2.No. VDA Register to DDC
 
        This section contain Number of VDS/Xenapp servers connected to each Delivery Controllers
 
    3.Last Active Time of Broker Service
 
        As name describe
 
    4.Last time contacted Licensing Server
 
        As name describe
 
    5.Licensing Server State as per Borker Service
 
    As name describe
 
 
 
 
    6.Status
 
 
.EXAMPLE.1
 
        We can use this command as below
 
        PS C:\Users\nadsiddi> Get-NSBrokercontroller
 
 
Name : Server01
State : Active
No. VDA Register to DDC : 11
Last Active Time of Broker Service : 2/27/2018 1:06:17 PM
Last time contacted Licensing Server : 2/24/2018 1:29:23 AM
Licensing Server State as per Borker Service : 2/24/2018 1:29:23 AM
 
Name : Server02
State : Active
No. VDA Register to DDC : 2
Last Active Time of Broker Service : 2/27/2018 1:06:17 PM
Last time contacted Licensing Server : 2/24/2018 1:27:48 AM
Licensing Server State as per Borker Service : 2/24/2018 1:27:48 AM
 
 
 
.EXAMPLE.2
     
    Using the below methoid will help to collect the error log at error.log file
     
   Get-NSBrokercontroller -Error 'E:\Scripts\Nadeem-Testing\error.log'
 
 
.EXAMPLE.3
 
    Using the below methoid will help to catch the warning messages under the variable $Catchwarning
 
   Get-NSBrokercontroller -WarningVariable $Catchwarning
 
.FUNCTIONALITY
   This give latest status of Delivery Controllers
#>



                      [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     
                     
                     [switch]$LogErrors
)
$Controllers = Get-BrokerController | select dnsname, State, desktopsRegistered, LastActivitytime, LastLicensingServerEvent, LastLicensingServerEventtime


foreach ( $Controller in $Controllers ){

Write-Verbose "Getting information for Delivery controller"

$props = [Ordered]@{'Name' = $Controller.dnsname;
          'State' = $Controller.State;
          'No. VDA Register to DDC ' = $Controller.desktopsRegistered;
          'Last Active Time of Broker Service' = $Controller.LastActivitytime;
          'Last time contacted Licensing Server' = $Controller.LastLicensingServerEventTime;
          'Licensing Server State as per Borker Service' = $Controller.LastLicensingServerEventTime}


Write-Verbose "Completed Getting information for Delivery controller"

New-Object -TypeName PSObject -Property $props

}

}

function Get-NSInfoDisk {

<#
.Synopsis
   This command provide Disk information on all the Xenapp servers and Delivery Controller
 
.DESCRIPTION
    
   The Get-NSInfoDisk provides below information.
    
   1. Server name
    
   2. Drive
    
   3. Size in GB
    
   4. Free Size in Percentage
    
   5. Free Size in GB
    
     
 
 
 
 
    
 
.EXAMPLE
 
        Using the below method you can get only C Drive details of all the servers and export
        it to some location.
 
        We can change or modify it as per our requirement.
 
   Get-NSInfoDisk | Where-Object {$_.Drive -eq 'C:'} | Out-File 'E:\Scripts\Nadeem-Testing\Result.csv'
 
 
.EXAMPLE
 
    Using the below command we can get Drive space details for only particular or specfic server.
 
     
   Get-NSInfoDisk -Computers Server01
 
 
Drive : C:
ServerName : Server01
Size : 60
Free : 28.32
FreePct : 47
 
Drive : E:
ServerName : Server01
Size : 30
Free : 23.89
FreePct : 80
 
 
.EXAMPLE
 
        Using the below command we will get the Drive information of all Xenapp and Delivery Controller.
 
 
 
            Get-NSInfoDisk
 
 
Drive : C:
ServerName : Server01
Size : 120
Free : 56.85
FreePct : 48
 
Drive : E:
ServerName : Server01
Size : 30
Free : 15.78
FreePct : 53
 
Drive : C:
ServerName : Server02
Size : 120
Free : 50.03
FreePct : 42
 
Drive : E:
ServerName : Server02
Size : 30
Free : 16.39
FreePct : 55
 
Drive : C:
ServerName : Server03
Size : 60
Free : 24.09
FreePct : 40
 
Drive : E:
ServerName : Server03
Size : 30
Free : 19.95
FreePct : 67
 
 
 
 
.ROLE
 
 
   The role this cmdlet belongs to System information
 
 
.FUNCTIONALITY
 
   This command provide Disk information on all the Xenapp servers
#>




                    [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     
                     [ValidateCount(1,30)]
                     [Alias ('hostname')]
                     [string[]]$Computers=(Get-BrokerMachine).DNSName + (Get-BrokerController).DNSName,
                     
                     [switch]$LogErrors
)


 
Write-Verbose "Checking Test-connection"

Foreach ($C in $Computers) {

$pingresult = Test-Connection -ComputerName $C -BufferSize 16 -Count 1 -Quiet 
             
                        

If ($pingresult -eq 'TRUE') {
Write-Verbose "Checking WMI Disk $_"



$drives = Get-WmiObject -class Win32_LogicalDisk -ComputerName $C `
-Filter "DriveType=3" -ErrorAction Continue
   
Write-Verbose "Completed WMI Disk $_"





                            }

Else  
            {    #If server is offline, log error in logfile
            Write-Verbose "adding to $Errorlog"
            Write-Verbose "$C Failed for getting WMI Object"
            Write-Warning "$C Failed for getting WMI Object" 

           $C + " is offline or does not exist" | Out-File $ErrorLog -Append 

           Write-Verbose "Complted to $Errorlog"
          }                             
                                    

Write-Verbose "Getting information for Drive $drive"

foreach ($drive in $drives) {

$props = @{'Drive'=$drive.DeviceID;
'ServerName'=$drive.PSComputerName;
'Size'=$drive.size / 1GB -as [int];
'Free'="{0:N2}" -f ($drive.freespace / 1GB);
'FreePct'=$drive.freespace / $drive.size * 100 -as [int]}

Write-Verbose "Completed Getting information for Drive $drive"

New-Object -TypeName PSObject -Property $props

}
}
}

function Get-NSVDA {


<#
.Synopsis
    
   The Get-NSVDA command provide information about all the Xenapp/VDA servers
 
 
.DESCRIPTION
    
   Get-NSVDA provides below information
 
 
   1. ServerName
 
   2. IP address of the Xenapp/VDA Server
 
   3. Number of session count on the Xenapp/VDA Server
 
   4. Delivery Controller Name to which the Xenapp/VDA Server reporting.
 
   5. Maintenamce Mode Status
 
   6. Reporting Status
 
   7. Last time connection time
 
 
 
.EXAMPLE
         
        This command provide information of all the Xenapp/VDA Server
   
        Get-NSVDA
 
 
        ServerName : Server01
        IP : 11.10.1.11
        State : Registered
        IsMaintenanceModeON : False
        Session Count : 2
        Last Connection : 2/28/2018 9:03:56 AM
        Reporting to DDC : ServerDDC01
 
        ServerName : Server01
        IP : 11.10.1.11
        State : Registered
        IsMaintenanceModeON : False
        Session Count : 3
        Last Connection : 2/28/2018 9:48:28 AM
        Reporting to DDC : ServerDDC02
 
 
 
 
   
 
 
.EXAMPLE.2
     
    Using the below methoid will help to collect the error log at error.log file
     
   Get-NSBrokercontroller -Error 'E:\Scripts\Nadeem-Testing\error.log'
 
 
.EXAMPLE.3
 
    Using the below methoid will help to catch the warning messages under the variable $Catchwarning
 
   Get-NSBrokercontroller -WarningVariable $Catchwarning
 
 
 
.ROLE
 
   This comes under Citrix Dashboard
 
 
.FUNCTIONALITY
   The functionality that best describes this cmdlet
#>







                      [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     
                     
                     [switch]$LogErrors
)

$VDAS = Get-BrokerMachine | Select DNSName, IPAddress,RegistrationState, InMaintenanceMode, SessionCount, LastConnectionTime, ControllerDNSName

foreach ($VDA in $VDAS) {

Write-Verbose "Getting information for VDA $VDA"

 
$props = [Ordered]@{'ServerName' = $VDA.dnsname;
                          'IP'=$VDA.IPAddress
                          'State' = $VDA.RegistrationState;
                          'IsMaintenanceModeON' = $VDA.InMaintenanceMode;
                          'Session Count' = $VDA.SessionCount;
                          'Last Connection' = $VDA.LastConnectionTime;
                          'Reporting to DDC' = $VDA.ControllerDNSName}



Write-Verbose "Completed Getting information for VDA $VDA"



New-Object -TypeName PSObject -Property $props

}

}


function Get-NSICAPORT {

<#
.Synopsis
    
   The Get-NSICAPORT command provide status of ICA Port (1494) of Xenapp/VDA Servers.
 
 
.DESCRIPTION
    
   Get-NSICAPORT provides below information
 
 
   1. Xenapp/VDA ServerName
 
   2. IP address of the Xenapp/VDA Server
 
   3. ICA PORT Number
 
   4. ICA Port Status.
 
  
 
 
.EXAMPLE
         
        This command provide information of all the ICA Port on Xenapp/VDA Server
   
        Get-NSICAPORT
 
        ComputerName PingSucceeded RemotePort TcpTestSucceeded
        ------------ ------------- ---------- ----------------
        Server011 TRUE 1494 TRUE
        Server012 TRUE 1494 TRUE
        Server013 TRUE 1494 TRUE
        Server014 TRUE 1494 TRUE
        
 
 
 
         
        .EXAMPLE.2
 
        We can get ICA Port status of single server too.
 
         Get-NSICAPORT -VDAMachine Server008
 
        ComputerName PingSucceeded RemotePort TcpTestSucceeded
        ------------ ------------- ---------- ----------------
        Server008
 
.EXAMPLE.3
     
    Using the below methoid will help to collect the error log at error.log file
     
   Get-NSICAPORT -Error 'E:\Scripts\Nadeem-Testing\error.log'
 
 
.EXAMPLE.4
 
    Using the below methoid will help to catch the warning messages under the variable $Catchwarning
 
   Get-NSICAPORT -WarningVariable $Catchwarning
 
 
 
.ROLE
 
   This comes under Citrix Dashboard
 
 
.FUNCTIONALITY
   The functionality that best describes this cmdlet
#>



                [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     
                     [ValidateCount(1,30)]
                     [Alias ('Computers')]
                     [string[]]$VDAMachine = (Get-BrokerMachine).DNSName,
                     
                     [switch]$LogErrors
)




foreach ($Machine in $VDAMachine) {

Write-Verbose "Getting information for Machine $Machine"

Test-NetConnection $Machine -Port 1494 |select ComputerName, PingSucceeded, RemotePort, TcpTestSucceeded

Write-Verbose "Completed Getting information for Machine $Machine"

}



}


function Get-NSDBStatus {


<#
.Synopsis
   Using the Get-NSDBStatus will get the current status of Delivery Controllers and the database
 
.DESCRIPTION
 
    This command provide details infoamtion about the Delivery Controllers and below database
 
    It contain below information.
 
    1.BrokerDBConnection
 
        Connection between the broker delivery controller and the Database
 
    2.MonitorDBConnection
 
        Connection between the delivery controller and the Monitoring Database
 
    3.LogDBConnection
 
        Connection between the delivery controller and the Log Database
 
    4.AcctDBConnection
 
        Connection between the delivery controller and the Acct Database
 
    5.AdminDBConnection
 
         Connection between the delivery controller and the Admin Database
 
 
 
.EXAMPLE.1
 
        We can use this command as below
 
        PS C:\Users\nadsiddi> Get-NSDBStatus
 
 
 
 
 
.EXAMPLE.2
 
    We can also use the command to get the Database status of perticuler Delivery Controller
 
PS C:\Users\nadsiddi> Get-NSDBStatus -DeliveryController Server002
 
 
 
.EXAMPLE.3
     
    Using the below methoid will help to collect the error log at error.log file
     
   Get-NSBrokercontroller -Error 'E:\Scripts\Nadeem-Testing\error.log'
 
 
.EXAMPLE.4
 
    Using the below methoid will help to catch the warning messages under the variable $Catchwarning
 
   Get-NSBrokercontroller -WarningVariable $Catchwarning
 
.FUNCTIONALITY
   This give latest status of Delivery Controllers
#>



                      [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     [Alias ('hostname')]
                     [string[]]$DeliveryController=(Get-BrokerController).DNSName,
                     
                     [switch]$LogErrors
)




foreach ($DC in $DeliveryController) {

Write-Verbose "working for $DC"

$Database02 = Get-BrokerDBConnection
$Database03 = Get-MonitorDBConnection
$Database04 = Get-LogDBConnection
$Database05 = Get-AcctDBConnection
$Database06 = Get-AdminDBConnection


$props = [Ordered]@{'DeliveryController' = $DC;
'BrokerDBConnection' = $Database02;
'MonitorDBConnection' = $Database03;
'LogDBConnection' = $Database04;
'AcctDBConnection' = $Database05;
'AdminDBConnection' = $Database06}

$obj = New-Object -TypeName PSObject -Property $props
       Write-Output $obj


}
}


function Get-NSDCServiceStatus {


<#
.Synopsis
   Using the NSDCServiceStatus will get the current status of Delivery Controllers Services
 
.DESCRIPTION
 
    This command provide details information about the Delivery Controllers and below Services
 
    It contain below information.
 
    1.AcctServiceStatus
 
         
 
    2.ConfigServiceStatus
 
         
 
    3.AdminServiceStatus
 
         
 
    4.BrokerServiceStatus
 
         
 
    5.LogServiceStatus
 
          
 
    6.MonitorServiceStatus
 
          
 
 
 
 
.EXAMPLE.1
 
        PS C:\Users\nadsiddi> Get-NSDCServiceStatus
VERBOSE: working for Server008
 
 
DeliveryController : Server008
AcctServiceStatus : OK
ConfigServiceStatus : OK
AdminServiceStatus : OK
BrokerServiceStatus : OK
LogServiceStatus : OK
MonitorServiceStatus : OK
 
VERBOSE: working for Server009.com
DeliveryController : Server009.com
AcctServiceStatus : OK
ConfigServiceStatus : OK
AdminServiceStatus : OK
BrokerServiceStatus : OK
LogServiceStatus : OK
MonitorServiceStatus : OK
 
 
.EXAMPLE.2
 
    We can also use the command to get the Database status of perticuler Delivery Controller
 
     
PS C:\Users\nadsiddi> Get-NSDCServiceStatus -DeliveryController Server009
VERBOSE: working for Server009
 
 
DeliveryController : Server009
AcctServiceStatus : OK
ConfigServiceStatus : OK
AdminServiceStatus : OK
BrokerServiceStatus : OK
LogServiceStatus : OK
MonitorServiceStatus : OK
 
 
 
.EXAMPLE.3
     
    Using the below methoid will help to collect the error log at error.log file
     
   Get-NSBrokercontroller -Error 'E:\Scripts\Nadeem-Testing\error.log'
 
 
.EXAMPLE.4
 
    Using the below methoid will help to catch the warning messages under the variable $Catchwarning
 
   Get-NSBrokercontroller -WarningVariable $Catchwarning
 
.FUNCTIONALITY
   This give latest status of Delivery Controllers
#>



                      [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     [Alias ('hostname')]
                     [string[]]$DeliveryController=(Get-BrokerController).DNSName,
                     
                     [switch]$LogErrors
)




foreach ($DC in $DeliveryController) {

Write-Verbose "working for $DC"

$XenappService22 = Get-AcctServiceStatus
$XenappService23 = Get-ConfigServiceStatus
$XenappService24 = Get-AdminServiceStatus 
$XenappService25 = Get-BrokerServiceStatus
$XenappService26 = Get-LogServiceStatus
$XenappService27 = Get-MonitorServiceStatus

$props = [Ordered]@{'DeliveryController' = $DC;
'AcctServiceStatus' = $XenappService22;
'ConfigServiceStatus' = $XenappService3;
'AdminServiceStatus' = $XenappService24;
'BrokerServiceStatus' = $XenappService25;
'LogServiceStatus' = $XenappService26;
'MonitorServiceStatus' = $XenappService27}

$obj = New-Object -TypeName PSObject -Property $props
       Write-Output $obj


}
}


function Get-NSLicenses {


<#
.Synopsis
   Using the Get-NSLicenses will get the current status of Licenses
 
.DESCRIPTION
 
    This command provide details infoamtion about the Licenses
 
    It contain below information.
 
    1.LicenseServerName
         
        As name describe
 
    2.LicenseServerPort
 
        As name describe
 
    3.Active Sessions
 
        As name describe
 
    4.Peak users Concurrent Connected Count
 
        The peak number of concurrent license users
 
    5.Licensing Module
 
    As name describe
 
 
 
.EXAMPLE.1
     
    Using the below methoid will help to collect the error log at error.log file
     
   Get-NSLicenses -Error 'E:\Scripts\Nadeem-Testing\error.log'
 
 
.EXAMPLE.2
 
    Using the below methoid will help to catch the warning messages under the variable $Catchwarning
 
   Get-NSLicenses -WarningVariable $Catchwarning
 
.FUNCTIONALITY
   This give latest status of Delivery Controllers
#>



                      [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     
                     
                     [switch]$LogErrors
)

$License = Get-BrokerSite

foreach ( $Licenses in $License ){

Write-Verbose "Getting information for License"

$props = [Ordered]@{'LicenseServerName' = $Licenses.LicenseServerName;
          'LicenseServerPort' = $Licenses.LicenseServerPort;
          'Active Sessions' = $Licenses.LicensedSessionsActive;
          'Peak Concurrent Connection Count' = $Licenses.PeakConcurrentLicenseUsers;
          'Module' = $Licenses.LicenseModel;
          'Is There Any Grace Period' = $Licenses.LicensingGracePeriodActive;
          'Is LocalHostCacheEnabled' = $Licenses.LocalHostCacheEnabled}


Write-Verbose "Completed Getting information for Delivery controller"

New-Object -TypeName PSObject -Property $props

}

}


function Get-NSInfra {


<#
.Synopsis
    
   The Get-NSInfra command provide information about all the Xenapp/VDA servers
 
 
.DESCRIPTION
    
   Get-NSInfra provides below information
 
 
   1. ServerName
 
   2. LastBootTime
 
   3. Total RAM
 
   4. FreeRam
 
   5. UsedRAM
 
   6. RAMPercentUsed
 
   7. Avg.CPUUsage
    
   8. PageFile
 
   9. AllocatedBaseSize_MB
 
   10. PeakUsage_MB
 
   11. CurrentUsage_MB
 
 
 
.EXAMPLE.1
         
        This command provide information of all the Xenapp/VDA Server
   
        Get-NSInfra
 
 
        ServerName : Server009
        LastBootTime : 3/17/2018 6:56:36 AM
        Total RAM : 4
        FreeRam : 0.57
        UsedRAM : 3.43
        RAMPercentUsed : 14.26
        Avg.CPUUsage : 32.6
        PageFile : C:\pagefile.sys
        AllocatedBaseSize_MB : 4352
        PeakUsage_MB : 139
        CurrentUsage_MB : 109
        isTempPageFile : False
 
 
 
 
 
 
.EXAMPLE.2
 
        PS C:\Users\nadsiddi> Get-NSInfra -Computers Server008
 
 
            ServerName : Server008
            LastBootTime : 3/16/2018 9:38:37 PM
            Total RAM : 4
            FreeRam : 1.58
            UsedRAM : 2.42
            RAMPercentUsed : 39.52
            Avg.CPUUsage : 3.4
            PageFile : C:\pagefile.sys
            AllocatedBaseSize_MB : 704
            PeakUsage_MB : 173
            CurrentUsage_MB : 41
 
   
 
 
 
 
.EXAMPLE.3
     
    Using the below methoid will help to collect the error log at error.log file
     
   Get-NSInfra -Error 'E:\Scripts\Nadeem-Testing\error.log'
 
 
.EXAMPLE.4
 
    Using the below methoid will help to catch the warning messages under the variable $Catchwarning
 
   Get-NSInfra -WarningVariable $Catchwarning
 
 
 
.ROLE
 
   This comes under Citrix Dashboard
 
 
.FUNCTIONALITY
   The functionality that best describes this cmdlet
#>







                      [CmdletBinding()]

param(
    
                    [Parameter(Mandatory=$false,
                               ValueFromPipeline=$True)]
                     [ValidateCount(1,30)]
                     [Alias ('hostname')]
                     [string[]]$Computers=(Get-BrokerMachine).DNSName + (Get-BrokerController).DNSName,
                     
                     [switch]$LogErrors
)







foreach ($computer in $Computers)  {

Try {

Write-Verbose "Getting RAM Details of $computer"

$WMI = Get-CimInstance -ClassName win32_operatingsystem -ComputerName $computer -ErrorAction Stop

Write-Verbose "Completed RAM Details of $computer"

Write-Verbose "Getting CPU Counter of $computer"

$CpuUsage01 = (get-counter -ComputerName $computer -Counter "\Processor(_Total)\% Processor Time" -SampleInterval 1 -MaxSamples 5 -ErrorAction Stop | select -ExpandProperty countersamples | select -ExpandProperty cookedvalue | Measure-Object -Average).average
        

Write-Verbose "Completed CPU Counter of $computer"

$PageFileUsage = Get-CimInstance -ClassName 'Win32_PageFileUsage' -ComputerName $computer

Write-Verbose "Getting PageFile Details of $computer"


Write-Verbose "Completed PageFile Details of $computer"


} 

Catch { "Error returned while checking the CPU usage for $computer. Perfmon Counters may be fault"| Out-File $ErrorLog -Append  } 
  

 
 $TotalRAM = ([int]($WMI.TotalVisibleMemorySize/1mb))
 $FreeRAM = ([math]::Round($WMI.FreePhysicalMemory/1mb,2))
 $UsedRAM = $TotalRAM - $FreeRAM 
 $RAMPercentUsed = [math]::Round(($WMI.FreePhysicalMemory/$WMI.TotalVisibleMemorySize)*100,2)
 $CpuUsage = [math]::round($CpuUsage01, 1)

        
    
 
$props = [Ordered]@{'ServerName' = $WMI.CSName;
                     'LastBootTime' = $WMI.LastBootUpTime
                    'Total RAM'= $TotalRAM
                    'FreeRam' = $FreeRAM
                    'UsedRAM' = $UsedRAM
                    'RAMPercentUsed' = $RAMPercentUsed
                    'Avg.CPUUsage' = $CpuUsage
                    'PageFile' = $PageFileUsage.Name 
                    'AllocatedBaseSize_MB' = $PageFileUsage.AllocatedBaseSize 
                     'PeakUsage_MB' = $PageFileUsage.PeakUsage
                     'CurrentUsage_MB' = $PageFileUsage.CurrentUsage 
                      
                     


                   }



#Write-Verbose "Completed Getting information for VDA $VDA"



New-Object -TypeName PSObject -Property $props

}

}




##############################################################################


$script = ''
function ConvertTo-NSEnhancedHTML {
<#
.SYNOPSIS
Provides an enhanced version of the ConvertTo-HTML command that includes
inserting an embedded CSS style sheet, JQuery, and JQuery Data Tables for
interactivity. Intended to be used with HTML fragments that are produced
by ConvertTo-NSEnhancedHTMLFragment. This command does not accept pipeline
input.
 
 
.PARAMETER jQueryURI
A Uniform Resource Indicator (URI) pointing to the location of the
jQuery script file. You can download jQuery from www.jquery.com; you should
host the script file on a local intranet Web server and provide a URI
that starts with http:// or https://. Alternately, you can also provide
a file system path to the script file, although this may create security
issues for the Web browser in some configurations.
 
 
Tested with v1.8.2.
 
 
Defaults to http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js, which
will pull the file from Microsoft's ASP.NET Content Delivery Network.
 
 
.PARAMETER jQueryDataTableURI
A Uniform Resource Indicator (URI) pointing to the location of the
jQuery Data Table script file. You can download this from www.datatables.net;
you should host the script file on a local intranet Web server and provide a URI
that starts with http:// or https://. Alternately, you can also provide
a file system path to the script file, although this may create security
issues for the Web browser in some configurations.
 
 
Tested with jQuery DataTable v1.9.4
 
 
Defaults to http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.min.js,
which will pull the file from Microsoft's ASP.NET Content Delivery Network.
 
 
.PARAMETER CssStyleSheet
The CSS style sheet content - not a file name. If you have a CSS file,
you can load it into this parameter as follows:
 
 
    -CSSStyleSheet (Get-Content MyCSSFile.css)
 
 
Alternately, you may link to a Web server-hosted CSS file by using the
-CssUri parameter.
 
 
.PARAMETER CssUri
A Uniform Resource Indicator (URI) to a Web server-hosted CSS file.
Must start with either http:// or https://. If you omit this, you
can still provide an embedded style sheet, which makes the resulting
HTML page more standalone. To provide an embedded style sheet, use
the -CSSStyleSheet parameter.
 
 
.PARAMETER Title
A plain-text title that will be displayed in the Web browser's window
title bar. Note that not all browsers will display this.
 
 
.PARAMETER PreContent
Raw HTML to insert before all HTML fragments. Use this to specify a main
title for the report:
 
 
    -PreContent "<H1>My HTML Report</H1>"
 
 
.PARAMETER PostContent
Raw HTML to insert after all HTML fragments. Use this to specify a
report footer:
 
 
    -PostContent "Created on $(Get-Date)"
 
 
.PARAMETER HTMLFragments
One or more HTML fragments, as produced by ConvertTo-NSEnhancedHTMLFragment.
 
 
    -HTMLFragments $part1,$part2,$part3
 
 
 
#>

    [CmdletBinding()]
    param(
        [string]$jQueryURI = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js',
        [string]$jQueryDataTableURI = 'http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.3/jquery.dataTables.min.js',
        [Parameter(ParameterSetName='CSSContent')][string[]]$CssStyleSheet,
        [Parameter(ParameterSetName='CSSURI')][string[]]$CssUri,
        [string]$Title = 'Report',
        [string]$PreContent,
        [string]$PostContent,
        [Parameter(Mandatory=$True)][string[]]$HTMLFragments
    )


    <#
        Add CSS style sheet. If provided in -CssUri, add a <link> element.
        If provided in -CssStyleSheet, embed in the <head> section.
        Note that BOTH may be supplied - this is legitimate in HTML.
    #>

    Write-Verbose "Making CSS style sheet"
    $stylesheet = ""
    if ($PSBoundParameters.ContainsKey('CssUri')) {
        $stylesheet = "<link rel=`"stylesheet`" href=`"$CssUri`" type=`"text/css`" />"
    }
    if ($PSBoundParameters.ContainsKey('CssStyleSheet')) {
        $stylesheet = "<style>$CssStyleSheet</style>" | Out-String
    }


    <#
        Create the HTML tags for the page title, and for
        our main javascripts.
    #>

    Write-Verbose "Creating <TITLE> and <SCRIPT> tags"
    $titletag = ""
    if ($PSBoundParameters.ContainsKey('title')) {
        $titletag = "<title>$title</title>"
    }
    $script += "<script charset=`"utf8`" type=`"text/javascript`" src=`"$jQueryURI`"></script>`n<script charset=`"utf8`" type=`"text/javascript`" src=`"$jQueryDataTableURI`"></script>"


    <#
        Render supplied HTML fragments as one giant string
    #>

    Write-Verbose "Combining HTML fragments"
    $body = $HTMLFragments | Out-String


    <#
        If supplied, add pre- and post-content strings
    #>

    Write-Verbose "Adding Pre and Post content"
    if ($PSBoundParameters.ContainsKey('precontent')) {
        $body = "$PreContent`n$body"
    }
    if ($PSBoundParameters.ContainsKey('postcontent')) {
        $body = "$body`n$PostContent"
    }


    <#
        Add a final script that calls the datatable code
        We dynamic-ize all tables with the .enhancedhtml-dynamic-table
        class, which is added by ConvertTo-NSEnhancedHTMLFragment.
    #>

    Write-Verbose "Adding interactivity calls"
    $datatable = ""
    $datatable = "<script type=`"text/javascript`">"
    $datatable += '$(document).ready(function () {'
    $datatable += "`$('.enhancedhtml-dynamic-table').dataTable();"
    $datatable += '} );'
    $datatable += "</script>"


    <#
        Datatables expect a <thead> section containing the
        table header row; ConvertTo-HTML doesn't produce that
        so we have to fix it.
    #>

    Write-Verbose "Fixing table HTML"
    $body = $body -replace '<tr><th>','<thead><tr><th>'
    $body = $body -replace '</th></tr>','</th></tr></thead>'


    <#
        Produce the final HTML. We've more or less hand-made
        the <head> amd <body> sections, but we let ConvertTo-HTML
        produce the other bits of the page.
    #>

    Write-Verbose "Producing final HTML"
    ConvertTo-HTML -Head "$stylesheet`n$titletag`n$script`n$datatable" -Body $body  
    Write-Debug "Finished producing final HTML"


}


function ConvertTo-NSEnhancedHTMLFragment {
<#
.SYNOPSIS
Creates an HTML fragment (much like ConvertTo-HTML with the -Fragment switch
that includes CSS class names for table rows, CSS class and ID names for the
table, and wraps the table in a <DIV> tag that has a CSS class and ID name.
 
 
.PARAMETER InputObject
The object to be converted to HTML. You cannot select properties using this
command; precede this command with Select-Object if you need a subset of
the objects' properties.
 
 
.PARAMETER EvenRowCssClass
The CSS class name applied to even-numbered <TR> tags. Optional, but if you
use it you must also include -OddRowCssClass.
 
 
.PARAMETER OddRowCssClass
The CSS class name applied to odd-numbered <TR> tags. Optional, but if you
use it you must also include -EvenRowCssClass.
 
 
.PARAMETER TableCssID
Optional. The CSS ID name applied to the <TABLE> tag.
 
 
.PARAMETER DivCssID
Optional. The CSS ID name applied to the <DIV> tag which is wrapped around the table.
 
 
.PARAMETER TableCssClass
Optional. The CSS class name to apply to the <TABLE> tag.
 
 
.PARAMETER DivCssClass
Optional. The CSS class name to apply to the wrapping <DIV> tag.
 
 
.PARAMETER As
Must be 'List' or 'Table.' Defaults to Table. Actually produces an HTML
table either way; with Table the output is a grid-like display. With
List the output is a two-column table with properties in the left column
and values in the right column.
 
 
.PARAMETER Properties
A comma-separated list of properties to include in the HTML fragment.
This can be * (which is the default) to include all properties of the
piped-in object(s). In addition to property names, you can also use a
hashtable similar to that used with Select-Object. For example:
 
 
 Get-Process | ConvertTo-NSEnhancedHTMLFragment -As Table `
               -Properties Name,ID,@{n='VM';
                                     e={$_.VM};
                                     css={if ($_.VM -gt 100) { 'red' }
                                          else { 'green' }}}
 
 
This will create table cell rows with the calculated CSS class names.
E.g., for a process with a VM greater than 100, you'd get:
 
 
  <TD class="red">475858</TD>
   
You can use this feature to specify a CSS class for each table cell
based upon the contents of that cell. Valid keys in the hashtable are:
 
 
  n, name, l, or label: The table column header
  e or expression: The table cell contents
  css or csslcass: The CSS class name to apply to the <TD> tag
   
Another example:
 
 
  @{n='Free(MB)';
    e={$_.FreeSpace / 1MB -as [int]};
    css={ if ($_.FreeSpace -lt 100) { 'red' } else { 'blue' }}
     
This example creates a column titled "Free(MB)". It will contain
the input object's FreeSpace property, divided by 1MB and cast
as a whole number (integer). If the value is less than 100, the
table cell will be given the CSS class "red." If not, the table
cell will be given the CSS class "blue." The supplied cascading
style sheet must define ".red" and ".blue" for those to have any
effect.
 
 
.PARAMETER PreContent
Raw HTML content to be placed before the wrapping <DIV> tag.
For example:
 
 
    -PreContent "<h2>Section A</h2>"
 
 
.PARAMETER PostContent
Raw HTML content to be placed after the wrapping <DIV> tag.
For example:
 
 
    -PostContent "<hr />"
 
 
.PARAMETER MakeHiddenSection
Used in conjunction with -PreContent. Adding this switch, which
needs no value, turns your -PreContent into clickable report
section header. The section will be hidden by default, and clicking
the header will toggle its visibility.
 
 
When using this parameter, consider adding a symbol to your -PreContent
that helps indicate this is an expandable section. For example:
 
 
    -PreContent '<h2>&diams; My Section</h2>'
 
 
If you use -MakeHiddenSection, you MUST provide -PreContent also, or
the hidden section will not have a section header and will not be
visible.
 
 
.PARAMETER MakeTableDynamic
When using "-As Table", makes the table dynamic. Will be ignored
if you use "-As List". Dynamic tables are sortable, searchable, and
are paginated.
 
 
You should not use even/odd styling with tables that are made
dynamic. Dynamic tables automatically have their own even/odd
styling. You can apply CSS classes named ".odd" and ".even" in
your CSS to style the even/odd in a dynamic table.
 
 
.EXAMPLE
 $fragment = Get-WmiObject -Class Win32_LogicalDisk |
             Select-Object -Property PSComputerName,DeviceID,FreeSpace,Size |
             ConvertTo-HTMLFragment -EvenRowClass 'even' `
                                    -OddRowClass 'odd' `
                                    -PreContent '<h2>Disk Report</h2>' `
                                    -MakeHiddenSection `
                                    -MakeTableDynamic
 
 
 You will usually save fragments to a variable, so that multiple fragments
 (each in its own variable) can be passed to ConvertTo-NSEnhancedHTML.
 
.NOTES
Consider adding the following to your CSS when using dynamic tables
(replace the * with .):
 
 
    *paginate_enabled_next, .paginate_enabled_previous {
        cursor:pointer;
        border:1px solid #222222;
        background-color:#dddddd;
        padding:2px;
        margin:4px;
        border-radius:2px;
    }
    *paginate_disabled_previous, .paginate_disabled_next {
        color:#666666;
        cursor:pointer;
        background-color:#dddddd;
        padding:2px;
        margin:4px;
        border-radius:2px;
    }
    *dataTables_info { margin-bottom:4px; }
 
 
This applies appropriate coloring to the next/previous buttons,
and applies a small amount of space after the dynamic table.
 
 
If you choose to make sections hidden (meaning they can be shown
and hidden by clicking on the section header), consider adding
the following to your CSS (replace the * with .):
 
 
    *sectionheader { cursor:pointer; }
    *sectionheader:hover { color:red; }
 
 
This will apply a hover-over color, and change the cursor icon,
to help visually indicate that the section can be toggled.
#>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$True,ValueFromPipeline=$True)]
        [object[]]$InputObject,


        [string]$EvenRowCssClass,
        [string]$OddRowCssClass,
        [string]$TableCssID,
        [string]$DivCssID,
        [string]$DivCssClass,
        [string]$TableCssClass,


        [ValidateSet('List','Table')]
        [string]$As = 'Table',


        [object[]]$Properties = '*',


        [string]$PreContent,


        [switch]$MakeHiddenSection,


        [switch]$MakeTableDynamic,


        [string]$PostContent
    )
    BEGIN {
        <#
            Accumulate output in a variable so that we don't
            produce an array of strings to the pipeline, but
            instead produce a single string.
        #>

        $out = ''


        <#
            Add the section header (pre-content). If asked to
            make this section of the report hidden, set the
            appropriate code on the section header to toggle
            the underlying table. Note that we generate a GUID
            to use as an additional ID on the <div>, so that
            we can uniquely refer to it without relying on the
            user supplying us with a unique ID.
        #>

        Write-Verbose "Precontent"
        if ($PSBoundParameters.ContainsKey('PreContent')) {
            if ($PSBoundParameters.ContainsKey('MakeHiddenSection')) {
               [string]$tempid = [System.Guid]::NewGuid()
               $out += "<span class=`"sectionheader`" onclick=`"`$('#$tempid').toggle(500);`">$PreContent</span>`n"
            } else {
                $out += $PreContent
                $tempid = ''
            }
        }


        <#
            The table will be wrapped in a <div> tag for styling
            purposes. Note that THIS, not the table per se, is what
            we hide for -MakeHiddenSection. So we will hide the section
            if asked to do so.
        #>

        Write-Verbose "DIV"
        if ($PSBoundParameters.ContainsKey('DivCSSClass')) {
            $temp = " class=`"$DivCSSClass`""
        } else {
            $temp = ""
        }
        if ($PSBoundParameters.ContainsKey('MakeHiddenSection')) {
            $temp += " id=`"$tempid`" style=`"display:none;`""
        } else {
            $tempid = ''
        }
        if ($PSBoundParameters.ContainsKey('DivCSSID')) {
            $temp += " id=`"$DivCSSID`""
        }
        $out += "<div $temp>"


        <#
            Create the table header. If asked to make the table dynamic,
            we add the CSS style that ConvertTo-NSEnhancedHTML will look for
            to dynamic-ize tables.
        #>

        Write-Verbose "TABLE"
        $_TableCssClass = ''
        if ($PSBoundParameters.ContainsKey('MakeTableDynamic') -and $As -eq 'Table') {
            $_TableCssClass += 'enhancedhtml-dynamic-table '
        }
        if ($PSBoundParameters.ContainsKey('TableCssClass')) {
            $_TableCssClass += $TableCssClass
        }
        if ($_TableCssClass -ne '') {
            $css = "class=`"$_TableCSSClass`""
        } else {
            $css = ""
        }
        if ($PSBoundParameters.ContainsKey('TableCSSID')) {
            $css += "id=`"$TableCSSID`""
        } else {
            if ($tempid -ne '') {
                $css += "id=`"$tempid`""
            }
        }
        $out += "<table $css>"


        <#
            We're now setting up to run through our input objects
            and create the table rows
        #>

        $fragment = ''
        $wrote_first_line = $false
        $even_row = $false


        if ($properties -eq '*') {
            $all_properties = $true
        } else {
            $all_properties = $false
        }


    }
    PROCESS {


        foreach ($object in $inputobject) {
            Write-Verbose "Processing object"
            $datarow = ''
            $headerrow = ''


            <#
                Apply even/odd row class. Note that this will mess up the output
                if the table is made dynamic. That's noted in the help.
            #>

            if ($PSBoundParameters.ContainsKey('EvenRowCSSClass') -and $PSBoundParameters.ContainsKey('OddRowCssClass')) {
                if ($even_row) {
                    $row_css = $OddRowCSSClass
                    $even_row = $false
                    Write-Verbose "Even row"
                } else {
                    $row_css = $EvenRowCSSClass
                    $even_row = $true
                    Write-Verbose "Odd row"
                }
            } else {
                $row_css = ''
                Write-Verbose "No row CSS class"
            }


            <#
                If asked to include all object properties, get them.
            #>

            if ($all_properties) {
                $properties = $object | Get-Member -MemberType Properties | Select -ExpandProperty Name
            }


            <#
                We either have a list of all properties, or a hashtable of
                properties to play with. Process the list.
            #>

            foreach ($prop in $properties) {
                Write-Verbose "Processing property"
                $name = $null
                $value = $null
                $cell_css = ''


                <#
                    $prop is a simple string if we are doing "all properties,"
                    otherwise it is a hashtable. If it's a string, then we
                    can easily get the name (it's the string) and the value.
                #>

                if ($prop -is [string]) {
                    Write-Verbose "Property $prop"
                    $name = $Prop
                    $value = $object.($prop)
                } elseif ($prop -is [hashtable]) {
                    Write-Verbose "Property hashtable"
                    <#
                        For key "css" or "cssclass," execute the supplied script block.
                        It's expected to output a class name; we embed that in the "class"
                        attribute later.
                    #>

                    if ($prop.ContainsKey('cssclass')) { $cell_css = $Object | ForEach $prop['cssclass'] }
                    if ($prop.ContainsKey('css')) { $cell_css = $Object | ForEach $prop['css'] }


                    <#
                        Get the current property name.
                    #>

                    if ($prop.ContainsKey('n')) { $name = $prop['n'] }
                    if ($prop.ContainsKey('name')) { $name = $prop['name'] }
                    if ($prop.ContainsKey('label')) { $name = $prop['label'] }
                    if ($prop.ContainsKey('l')) { $name = $prop['l'] }


                    <#
                        Execute the "expression" or "e" key to get the value of the property.
                    #>

                    if ($prop.ContainsKey('e')) { $value = $Object | ForEach $prop['e'] }
                    if ($prop.ContainsKey('expression')) { $value = $Object | ForEach $prop['expression'] }


                    <#
                        Make sure we have a name and a value at this point.
                    #>

                    if ($name -eq $null -or $value -eq $null) {
                        Write-Error "Hashtable missing Name and/or Expression key"
                    }
                } else {
                    <#
                        We got a property list that wasn't strings and
                        wasn't hashtables. Bad input.
                    #>

                    Write-Warning "Unhandled property $prop"
                }


                <#
                    When constructing a table, we have to remember the
                    property names so that we can build the table header.
                    In a list, it's easier - we output the property name
                    and the value at the same time, since they both live
                    on the same row of the output.
                #>

                if ($As -eq 'table') {
                    Write-Verbose "Adding $name to header and $value to row"
                    $headerrow += "<th>$name</th>"
                    $datarow += "<td$(if ($cell_css -ne '') { ' class="'+$cell_css+'"' })>$value</td>"
                } else {
                    $wrote_first_line = $true
                    $headerrow = ""
                    $datarow = "<td$(if ($cell_css -ne '') { ' class="'+$cell_css+'"' })>$name :</td><td$(if ($cell_css -ne '') { ' class="'+$cell_css+'"' })>$value</td>"
                    $out += "<tr$(if ($row_css -ne '') { ' class="'+$row_css+'"' })>$datarow</tr>"
                }
            }


            <#
                Write the table header, if we're doing a table.
            #>

            if (-not $wrote_first_line -and $as -eq 'Table') {
                Write-Verbose "Writing header row"
                $out += "<tr>$headerrow</tr><tbody>"
                $wrote_first_line = $true
            }


            <#
                In table mode, write the data row.
            #>

            if ($as -eq 'table') {
                Write-Verbose "Writing data row"
                $out += "<tr$(if ($row_css -ne '') { ' class="'+$row_css+'"' })>$datarow</tr>"
            }
        }
    }
    END {
        <#
            Finally, post-content code, the end of the table,
            the end of the <div>, and write the final string.
        #>

        Write-Verbose "PostContent"
        if ($PSBoundParameters.ContainsKey('PostContent')) {
            $out += "`n$PostContent"
        }
        Write-Verbose "Done"
        $out += "</tbody></table></div>"
        Write-Output $out
    }
}






$style = @"
<style>
body {
color:#333333;
font-family:Calibri,Tahoma;
font-size: 10pt;
}
h1 {
text-align:center;
color:#4B0082;
background-color:#00BFFF;
}
h2 {
border-top:1px solid #666666;
color:#4B0082;
background-color:#00BFFF;
}
th {
font-weight:bold;
color:#333333;
background-color:#BDB76B;
cursor:pointer;
}
.odd { background-color:#ffffff; }
.even { background-color:#dddddd; }
.paginate_enabled_next, .paginate_enabled_previous {
cursor:pointer;
border:1px solid #222222;
background-color:#dddddd;
padding:2px;
margin:4px;
border-radius:2px;
}
.paginate_disabled_previous, .paginate_disabled_next {
color:#666666;
cursor:pointer;
background-color:#dddddd;
padding:2px;
margin:4px;
border-radius:2px;
}
.dataTables_info { margin-bottom:4px; }
.sectionheader { cursor:pointer; }
.sectionheader:hover { color:red; }
.grid { width:100% }
.red {
color:red;
font-weight:bold;
}
 
.green {
color:green;
font-weight:bold;
}
 
.orange {
color:#FFA500;
font-weight:bold;
}
</style>
"@







Write-Verbose "Getting information for parameters Broker Controller"

$params = @{'As'='Table';
'PreContent'='<h2>&diams;Broker Controller</h2>'
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid'
'Properties'='Name', 'No. VDA Register to DDC ', 'Last Active Time of Broker Service', 'Last time contacted Licensing Server', 'Licensing Server State as per Borker Service',
@{n='Status';e={$_.State};css={if ($_.State -eq 'Active') { 'green' } else { 'red' }}}}
$html_BrokerController = Get-NSBrokercontroller |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed Getting information for parameters Broker Controller"



Write-Verbose "Getting information for parameters Disk Space"

$params = @{'As'='Table';
'PreContent'='<h2>&diams; Disks Space</h2>';
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid';
'Properties'='Drive',
@{n='ServerName';e={$_.ServerName}},
@{n='Size(GB)';e={$_.Size}},
@{n='Free(GB)';e={$_.Free};css={if ($_.FreePct -lt 20) { 'red' } else { 'green' }}},
@{n='Free(%)';e={$_.FreePct};css={if ($_.FreeePct -lt 20) { 'green' } else { 'red' }}}}
$html_NSInfoDisk = Get-NSInfoDisk |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed Getting information for parameters Disk Space"


Write-Verbose "Getting information for parameters VDA Status"

$params = @{'As'='Table';
'PreContent'='<h2>&diams; VDA Status</h2>';
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid';
'Properties'='ServerName', 'IP', 'Session Count', 'Last Connection', 'Reporting to DDC',
@{n='IsMaintenanceModeON';e={$_.IsMaintenanceModeON};css={if ($_.IsMaintenanceModeON -eq 'False') { 'red' } else { 'green' }}},
@{n='Status';e={$_.State};css={if ($_.State -eq 'Registered') { 'green' } else { 'red' }}}
}
$html_NSVDA = Get-NSVDA |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed Getting information for parameters VDA Status"



Write-Verbose "Getting information for parameters ICA Port Status"

$params = @{'As'='Table';
'PreContent'='<h2>&diams;ICA Port Status</h2>'
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid';
'Properties'='ComputerName',
@{n='Ping Status';e={$_.PingSucceeded};css={if ($_.PingSucceeded -eq 'TRUE') { 'green' } else { 'red' }}},
@{n='ICA PORT Number';e={$_.RemotePort}},
@{n='ICA PORT STATUS';e={$_.TcpTestSucceeded};css={if ($_.TcpTestSucceeded -eq 'TRUE') { 'green' } else { 'orange' }}}
}
$html_NSICAPORT = Get-NSICAPORT |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed Getting information for parameters ICA Port Status"


Write-Verbose "Getting information for parameters Database Status"


$params = @{'As'='Table';
'PreContent'='<h2>&diams;Database Connection Status</h2>'
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid';
'Properties'='DeliveryController', 'BrokerDBConnection', 'MonitorDBConnection', 'LogDBConnection', 'AcctDBConnection', 'AdminDBConnection'
}
$html_NSDBStatus = Get-NSDBStatus |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed Getting information for parameters Database Status"



Write-Verbose "Getting information for parameters Delivery Controller Services Status"

$params = @{'As'='Table';
'PreContent'='<h2>&diams;Delivery Controller Services Status</h2>'
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid';
'Properties'='DeliveryController',
@{n='AcctServiceStatus';e={$_.AcctServiceStatus};css={if ($_.AcctServiceStatus -eq 'OK') { 'green' } else { 'red' }}},
@{n='ConfigServiceStatus';e={$_.ConfigServiceStatus};css={if ($_.ConfigServiceStatus -eq 'OK') { 'green' } else { 'red' }}},
@{n='AdminServiceStatus';e={$_.AdminServiceStatus};css={if ($_.AdminServiceStatus -eq 'OK') { 'green' } else { 'red' }}},
@{n='BrokerServiceStatus';e={$_.BrokerServiceStatus};css={if ($_.BrokerServiceStatus -eq 'OK') { 'green' } else { 'red' }}},
@{n='LogServiceStatus';e={$_.LogServiceStatus};css={if ($_.LogServiceStatus -eq 'OK') { 'green' } else { 'red' }}},
@{n='MonitorServiceStatuss';e={$_.MonitorServiceStatus};css={if ($_.MonitorServiceStatus -eq 'OK') { 'green' } else { 'red' }}}

}
$html_NSDCServiceStatus = Get-NSDCServiceStatus |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed information for parameters Delivery Controller Services Status"


Write-Verbose "Getting information for parameters Licenses Status"

$params = @{'As'='Table';
'PreContent'='<h2>&diams;Licenses Status</h2>'
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid';
'Properties'='LicenseServerName', 'LicenseServerPort', 'Active Sessions', 'Peak Concurrent Connection Count', 'Module', 'Is There Any Grace Period', 'Is LocalHostCacheEnabled'

}
$html_NSLicenses = Get-NSLicenses |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed information for parameters Licenses Status"



Write-Verbose "Getting Infra Information for all the Servers"

$params = @{'As'='Table';
'PreContent'='<h2>&diams;Infra Status</h2>'
'EvenRowCssClass'='even';
'OddRowCssClass'='odd';
'MakeTableDynamic'=$true;
'TableCssClass'='grid';
'Properties'='ServerName', 'LastBootTime', 'Total RAM', 'FreeRam', 'UsedRAM', 'RAMPercentUsed', 'Avg.CPUUsage', 'PageFile', 'AllocatedBaseSize_MB', 'PeakUsage_MB', 'CurrentUsage_MB'


}
$html_NSInfra = Get-NSInfra |
ConvertTo-NSEnhancedHTMLFragment @params

Write-Verbose "Completed Infra Information for all the Servers"


Write-Verbose "Getting information for parameters Dashboard"

$params = @{'CssStyleSheet'=$style;
'Title'="Citrix Health Check Report";  #Modify the Title for the Report
'PreContent'="<h1>Dashboard for Citrix XXXXX Farm</h1>";   #Modify the Header of the Report
'PostContent'="Created by Nadeem Siddiqui on $(Get-Date)"; #Modify the footer of the Report
'HTMLFragments'=@($html_BrokerController,$html_NSDCServiceStatus, $html_NSDBStatus,$html_NSLicenses, $html_NSICAPORT, $html_NSVDA,$html_NSInfra, $html_NSInfoDisk)}
ConvertTo-NSEnhancedHTML @params |
Out-File -FilePath $Report

Write-Verbose "Completed Getting information for parameters Dashboard"

Write-Verbose "Dashboard report has been exported to location $Report"