Link to home
Start Free TrialLog in
Avatar of exchsvr
exchsvr

asked on

Powershell - Send popup message to single user on remote machine

I found a powershell script that will send a popup message to a remote machine, but I would like to be able to limit it to a specific user on that TS.  How can i modify the following script to send it to a specific user on that server?  

$name = read-host "Enter computer name"
$msg = read-host "Enter your message"
Invoke-WmiMethod -Path Win32_Process -Name Create -ArgumentList "msg * $msg" -ComputerName $name
Avatar of Muhammad Burhan
Muhammad Burhan
Flag of Pakistan image

Assume 'srv1.domain.com' is FQDN for that server then use Get-RDUserSession to retrieve the unique ID for a specific session, put that ID No. after -UnifiedSessionID.
Send-RDUserMessage -HostServer "Srv1.domain.com" -UnifiedSessionID 1 -MessageTitle "Message from Administrator" -MessageBody "You will be logged off in 10 minutes"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of exchsvr
exchsvr

ASKER

Thank you, this is exactly what is needed.  The rdusersession option required the remote desktop module to be installed so we couldn't use that.


Thanks!