Send-xRDS_User_Message.ps1
function Send-xRDS_User_Message { <# .DESCRIPTION Sends message to selected users from a sessions list. .PARAMETER Broker -ConnectionBroker - FQDN of RDS ConnectionBroker. .PARAMETER Message -Message - Message text to display for selected users. .PARAMETER Credential -Credential [Optional] - Query RDS Connection Broker resources under provided credentials. PARAMETER DisplayMessageSeconds -DisplayMessageSeconds [Optional] - Message display time in seconds (Default value is equivalent of 5 minutes). .EXAMPLE # Send message to a users on selected RDS Host servers: Send-xRDS_User_Message -ConnectionBroker ardscbl01.adatum.labnet -Message "Please call support for assistance." .LINK https://www.securemfa.com/downloads/mfa-rds-otp #> [CmdletBinding()] Param( [Parameter(Mandatory=$true)][string]$ConnectionBroker, [Parameter(Mandatory=$true)][string]$Message, [Int]$DisplayMessageSeconds = 300, [PSCredential]$Credential ) $SelectedUsers = Get-xRDS_UsersList -ConnectionBroker $ConnectionBroker -Credential $Credential Try { If ($SelectedUsers.UserName.Count -le 0) {Write-Host "No users have been selected." -ForegroundColor Cyan } else { Write-Host "Message: $Message Will display $DisplayMessageSeconds seconds to folowing users:" -ForegroundColor Cyan ; $SelectedUsers | foreach {Write-Host "Username: $($_.UserName) SID: $($_.SID) Collection: $($_.Collection) HOST: $($_.Host) " -ForegroundColor Cyan ; start-process msg "$($_.SID) /SERVER:$($_.Host) /TIME:$($DisplayMessageSeconds) $($Message)" -WindowStyle Hidden}} } Catch {Write-host $_.Exception.message -ForegroundColor Red} } |