Powershell: Send a message to all user within a Citrix Delivery Group

send-ctxmessage -DesktopGroupName DG1 -Time "20 Minutes"

You can add different parameters and put them into your message text!
So by adding a $Application parameter you will be able to do the following:
sent-ctxmessage -desktopgroupname DG1 -Time "20 Minutes" -Application "AppXY"
Modify your message:
Send-BrokerSessionMessage -AdminAddress $AdminAddress -InputObject $session -MessageStyle Information -Title "Update of $Application" -Text "In $Time there will be an Update for $Application."

What the User will receive:
Update of AppXY
In 20 Minutes there will be an Update for AppXY

function send-CTXmessage{
            $adminAddress = "Insert Name of Controller here!"
    $ErrorActionPreference = "Stop"
        Add-PSSnapin Citrix* -ErrorAction Stop
        $arrSrv = get-brokerMachine -adminAddress "$AdminAddress" | where-object {$_.DesktopGroupName -eq "$DesktopGroupName"} | select-object MachineName
         foreach ($srv in $arrSrv) {
                 $arrSessions = @()
                 $arrSessions = Get-BrokerSession -AdminAddress $AdminAddress -MachineName $srv.machineName | Sort-Object

                 foreach ($session in $arrSessions){
                     Send-BrokerSessionMessage -AdminAddress $AdminAddress -InputObject $session -MessageStyle Information -Title "Insert Message Title here" -Text "In $Time there will be some Update, please log off"                        
                     write-host "User "$session.UserFullName" Message send" -foregroundColor Green
        write-host "Caught an exception:" -ForegroundColor Red
        write-host "Exception Type: $($_.Exception.GetType().FullName)" -ForegroundColor Red
        write-host "Exception Message: $($_.Exception.Message)" -ForegroundColor Red
        write-host "--End Script--"

Citrix: RestartBrokerAgent for your Service Desk

If users cannot be logged off through the Citrix Director it mostly can be solved by restarting the Broker Agent (Citrix Desktop Service) Service.
It’s a short procedure but if done fast and dirty can cause many errors (by OSI Layer 8). I wrote a really small script so everyone can easily restart the service.

get-service -ComputerName $server -name BrokerAgent | restart-service -Verbose</code>

Just give it to the Service Desk and they can now restart the BrokerAgent with .\restartbrokeragent.ps1 -server XA-Server