Thursday, March 5, 2015

Citrix Desktop In Use

add-pssnapin Citrix.Broker.Admin.* -ErrorAction SilentlyContinue





clear



$DBG = Get-BrokerDesktopGroup | where {$_.Name -eq "IT" -and $_.Enabled -eq "True"}




#[Uint16] $TD

#[Uint16] $DIU


$TD = $DBG.TotalDesktops

$DIU = $DBG.DesktopsInUse

If ($TD -and $DIU -ne "null")



{

Write-Host "Desktop in Use:"$DIU"|DesktopsInUse="$DIU";0;$TD"



exit(0)

}

else


{

Write-Host "Unable to fetch the Get-BrokerDesktopGroup, please contact Chethan or Babu"



exit(2)

}


Cirtix Deskdtop Disconnected

add-pssnapin Citrix.Broker.Admin.* -ErrorAction SilentlyContinue





clear



$DBG = Get-BrokerDesktopGroup | where {$_.Name -eq "IT" -and $_.Enabled -eq "True"}




#[Uint16] $TD

#[Uint16] $DD


$TD = $DBG.TotalDesktops

$DD = $DBG.DesktopsDisconnected

If ($TD -and $DD -ne "null")



{

Write-Host "Desktops Disconnected:"$DD"|DesktopsDisconnected="$DD";0;$TD"



exit(0)

}

else


{

Write-Host "Unable to fetch the Get-BrokerDesktopGroup, please contact Chethan or Babu"



exit(2)

}


Citrix Desktop Available

add-pssnapin Citrix.Broker.Admin.* -ErrorAction SilentlyContinue





clear



$DBG = Get-BrokerDesktopGroup | where {$_.Name -eq "IT" -and $_.Enabled -eq "True"}




#[Uint16] $TD

#[Uint16] $DIU


$TD = $DBG.TotalDesktops

$DIU = $DBG.DesktopsInUse

$DD = $DBG.DesktopsDisconnected

$sobj = Get-BrokerDesktop | Where{$_.PowerState -eq "Off"}|Measure-Object -Line -Property PowerState | Select-Object Lines

$poweredoffdesktops = $sobj.Lines

If ($TD -and $DIU -and $Poweredoffdesktops -and $DD -ne "null")



{

$PAvail = ($TD-($DD+$DIU))

$Avail = $PAvail - $poweredoffdesktops

Write-Host "Total Desktop Available:"$Avail"|DesktopAvailble="$Avail";0;$TD"



exit(0)

}

else


{

Write-Host "Unable to fetch the Get-BrokerDesktopGroup, please contact Chethan or Babu"



exit(2)

}