Jump to content
Welcome to our new Citrix community!
  • 0

Citrix Studi - Colors for Maintenance Mode


Franco König

Question

3 answers to this question

Recommended Posts

  • 1

Hi,

I've created a simple PoSH script, which i think is useful for an administrator without going into too many detials. Feel free to customise it.  Run it from controller or you can schedule it to run hourly.

 

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

# Load only the snap-ins, which are used

if ((Get-PSSnapin "Citrix.Broker.Admin.*" -EA silentlycontinue) -eq $null) {

try { Add-PSSnapin Citrix.Broker.Admin.* -ErrorAction Stop }

catch { write-error "Error Get-PSSnapin Citrix.Broker.Admin.* Powershell snapin"; Return }

}

#Variables

$CBrokerSite = Get-BrokerSite

$CControllerDesktops = Get-BrokerController

$CBrokerMachine = Get-BrokerMachine

$CBrokerSession = Get-BrokerSession

$CReebootSchude = Get-BrokerRebootScheduleV2

$CBrokerSharedDesktop = Get-BrokerSharedDesktop | ? {$_.RegistrationState -eq 'registered' -and $_.OSType -like '*2012*'}

$CBrokerPrivateDesktop = Get-BrokerPrivateDesktop | ? {$_.RegistrationState -eq 'registered' -and $_.OSType -notlike '*2012*'}

#Function to get current Licensing usage Information

Function Current-LicenseInformation

{

$CBrokerSite | `

select @{N="Active Sessions"; E= {$_.LicensedSessionsActive}}, `

@{N="Total Unique Licensed Users"; E= {$_.TotalUniqueLicenseUsers}},`

@{N="Average Peak Users"; E= {$_.PeakConcurrentLicenseUsers}}

}

#Function to get current registered virtual machines per controller

Function Current-PerControllerRegisteredDesktops {

$CControllerDesktops | `

select @{N="Controller FullName"; E= {$_.DNSName}}, `

@{N="Registered Machines"; E= {$_.DesktopsRegistered}}

}

#Function to get current virtual machines in maintenance mode

Function Current-InMaintenanceModeVMs {

$CBrokerMachine | ? {$_.RegistrationState -like 'unreg*' } |`

select Machinename, RegistrationState, InMaintenanceMode

}

 

 

#Function to get current virtual machines Registration Status & Count

Function Current-RegisteredVMs{

$CBrokerMachine | ? {$_.RegistrationState -eq 'registered' -and $_.VMToolsState -notlike 'not*'} | `

select @{N="Registered Controller"; E= {$_.ControllerDnsName}}, `

@{N="VDA Worker"; E= {$_.MachineName}}, `

@{N="IP Address"; E= {$_.IPAddress}}, `

@{N="Logons"; E= {$_.WindowsConnectionSetting}}, `

@{N="Current ESXi Host"; E= {$_.HostingServerName}} | sort "Registered To"

}

 

#Function to get current sessions & Count

Function Current-BrokerSessions {

$CBrokerSession | `

select UserName, `

UserFullName,`

SessionState,`

SessionType,`

ClientName,`

ClientAddress,`

ClientPlatform,`

ClientVersion,`

HostedMachineName,`

HostingServerName,`

ProvisioningType,`

CatalogName |`

sort HostedMachineName

}

 

#Function to get current sessions & Count

Function Current-RebootSchedule {

$DayOfTheWeek = (get-date).DayOfWeek

$CReebootSchude | ? {$_.Day -eq "$DayOfTheWeek"} | select Name, DesktopGroupName, Frequency, StartTime, RebootDuration, Enabled | sort Name

}

############ COUNTS ########################

$CBrokerMachineInMaintCount = ($CBrokerMachine | ? {$_.RegistrationState -like 'unreg*'} | select Machinename, RegistrationState, InMaintenanceMode).count

$CBrokerRegisteredMachines = ($CBrokerMachine | ? {$_.RegistrationState -eq 'registered' -and $_.VMToolsState -notlike 'not*'} | select @{N="Registered To"; E= {$_.ControllerDnsName}}, MachineName, IPAddress, WindowsConnectionSetting, HostingServerName | sort "Registered To").count

$CBrokerSessionCount = ($CBrokerSession | select UserName, UserFullName, SessionState, SessionType, ClientName, ClientAddress, ClientPlatform, ClientVersion, HostedMachineName, HostingServerName, ProvisioningType, CatalogName | sort HostedMachineName).count

$CBrokerSharedDesktopCount = $CBrokerSharedDesktop.Count

$CBrokerPrivateDesktopCount = $CBrokerPrivateDesktop.Count

#####HTML Report ################

$head = "<style>

td {width:Auto; max-width:Auto; background-color:lightgrey;}

table {width:auto;}

th {font-size:14pt;background-color:Green;}

body {font-family:Calibri; font-size:15pt;}

</style>

<title>XenDesktop Report</title>"

$frag1 = Current-LicenseInformation| ConvertTo-Html -As Table -Fragment -PreContent "<h4>Current License Usage Information</h4>" | Out-String

$frag2 = Current-PerControllerRegisteredDesktops | ConvertTo-Html -As Table -Fragment -PreContent "<h4>Current Virtual Apps & Desktops Registration Status</h4>" | Out-String

$frag3 = Current-InMaintenanceModeVMs | ConvertTo-Html -As table -Fragment -PreContent "<h4>Current Machines In Maintenance Mode : $CBrokerMachineInMaintCount </h4>" | Out-String

$frag4 = Current-RegisteredVMs| ConvertTo-Html -As Table -Fragment -PreContent "<h4>Current Registered Virtual Machines : $CBrokerRegisteredMachines, Server VMs : $CBrokerSharedDesktopCount, Desktop VMs : $CBrokerPrivateDesktopCount </h4>" | Out-String

$frag5 = Current-BrokerSessions | ConvertTo-Html -As Table -Fragment -PreContent "<h4>Current Citrix Sessions : $CBrokerSessionCount </h4>" | Out-String

$frag6 = Current-RebootSchedule | ConvertTo-Html -As Table -Fragment -PreContent "<h4>Today's Server Reboot Schedule</h4>" | Out-String

#$datum = (Get-Date).ToString("s").Replace(":","-")

ConvertTo-Html -Head $head `

-PostContent $frag1, $frag2, $frag3, $frag4, $frag5, $frag6 -PreContent "<h4>Hourly XenDesktop Report</h4>" | Out-File "$env:Userprofile\documents\Hourly Citrix Report.html"

 

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...