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

Usage:
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{
    param( 
            [string]$DesktopGroupName,
            [string]$Time,
            $adminAddress = "Insert Name of Controller here!"
         )
    $ErrorActionPreference = "Stop"
    try
    {
 
        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
                 }
         }
        
    }
    catch
    {
        write-host "Caught an exception:" -ForegroundColor Red
        write-host "Exception Type: $($_.Exception.GetType().FullName)" -ForegroundColor Red
        write-host "Exception Message: $($_.Exception.Message)" -ForegroundColor Red
    }
    finally
    {
        write-host "--End Script--"
    }
 }