向域、跨体系结构中的所有活动用户发送锁定或一般消息

Sending out lockdown or general message to all active users in domain, cross-architecture

我正在尝试设置一个脚本,该脚本将向域中的所有用户发送消息 - Mixture,一些在 Windows 10 Surface Pro 上,一些在 Citrix VDI 上。

底部的 Citrix 部分不太正确,在开始会话时,我似乎需要将 Citrix 模块导入 DDC,即使我是通过 PS 会话(新- pssession) 到控制器。 VDI 用户桌面上的消息未出现,不确定原因...

      $Cred = Read-Host "enter-username e.g. domain\user.name" 
            $computers = Get-Content C:\Scripts\allcomputers.txt #| Where-Object { $_ } 

            #foreach ($computer in $computers) {


             #    Invoke-Command -computername $computer -scriptblock {msg * "INSERT MESSAGE TO STAFF HERE"} -Credential $cred

            }

           # Import-Module Citrix.XenDesktop.Admin?
           # Add-PSSnapin Citrix?


               $s = New-PSSession -cn DDC -Credential DOMAIN\Cred

               Invoke-Command -Session $s -ScriptBlock { $sessions = Get-BrokerSession -UserName DOMAIN\User ;
Send-BrokerSessionMessage $sessions -MessageStyle Information -Title TestTitle -Text TestMessage
               }

               Get-PSSession | Remove-PSSession

如果我在交互式会话中使用脚本块中的命令,模块似乎没有安装,因此注释掉了 2 行...:S

感谢您的帮助 - 将通过 PowerShell 向所有 Citrix XDT 会话发送消息的工作代码:

$s = New-PSSession -cn CitrixDDC -Credential Domain\Administrator

           Invoke-Command -Session $s -ScriptBlock { import-module 
           Citrix.XenDesktop.Admin; Add-PSSnapin Citrix.*; 

           $sessions = Get-BrokerSession -UserName Domain\* `

           Send-BrokerSessionMessage $sessions -MessageStyle Information -Title 
           TestTitle -Text TestMessage

           }

       Get-PSSession | Remove-PSSession