Question about [System.Windows.MessageBox]

Hello,

being a beginning programmer in PowerShell, I have a script I can send a message to all workstations in a domain which are powered on and which are currently logged on.

The message is being send as

Invoke-WmiMethod -Path Win32_Process -Name Create -ArgumentList “msg * $msg” -ComputerName $comp | Out-Null

but I would like to use the MessageBox.

Is this possible and how?

Any help is appreciated.

Thx

Philip

What is “msg * $msg”? This appears that it is running a msg.exe on the client and sending a passed message? This code is starting a process on the remote client, but not sure what msg is?

MSG.exe is an old way to send network messages. It’s similar to how an admin would send shutdown message to users. There used to be a messenger service you had to enable.

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/msg

What he’s doing with the * though is sending a message to all users of that particular computer, versus specifying a username, sessionname, sessionid. In my testing it always comes up as a message box already. What exactly are you seeing on the remote machines?

Please note the following.

  1. You can use msg.exe natively, you don't need to invoke a powershell command. Simply use msg /server:remotepc * 'message'
  2. You need administrative rights on the target nodes otherwise the message will be be sent to the local machine.
I hope this helps.