PowerShell - showing a message on remote computer screen

Darren Rose 496 Reputation points
2021-01-23T17:49:04.513+00:00

Hi

When I am running commands or installing software remotely using PowerShell - Invoke-Command etc I would like sometimes to be able to show a message on the remote screen so the user knows something is happening, or when work done etc.

I would like to if possible make this message look as professional as possible, e.g. better than just a standard winform message box if it can be done? perhaps more the style of the Windows 10 ones with coloured background and use of image if possible.

Spent a while googling but most seem to relate to using obsolete methods such as net-send or using msg.exe.

Thanks

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Darren Rose 496 Reputation points
    2021-01-24T17:48:18.183+00:00

    Just found this which on quick testing seems to work really well

    https://smsagent.blog/2019/06/11/just-for-fun-send-a-remote-toast-notification/

    Update - have spent further time testing this and it works really well to show a toast notification on remote computers in an AD environment, only amendment needed is changing location it stores image for toast as when running remotely the temp path it finds is admin rather than local user so just change it to a path all users can see and it works perfectly

    Further information on customizing the XML can be found at links below for info:-

    https://learn.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts?tabs=builder-syntax
    https://learn.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-schema

    1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. Chris 656 Reputation points
    2021-01-23T18:00:05.2+00:00

  2. Chris 656 Reputation points
    2021-01-24T13:06:24.647+00:00

    take a look auf sysinternal tool, psexec and use native msg or what else


  3. MotoX80 36,291 Reputation points
    2021-01-24T17:22:06.48+00:00

    Some thoughts that I had...

    I would like to if possible make this message look as professional as possible,

    If you want to do this in Powershell, you can use https://poshgui.com/ to design a form. It's a good tool, but might take some time to play with it and get it to look like you want. You would need to use PSEexec or the Task Scheduler to launch it in the context of the desktop user.

    If I was tasked with finding a solution to your issue, I would download the free Visual Studio Community edition and write a little VB or C# program that served as the message program. With VS you get a full IDE that you can use to get the form to look exactly like you want. It's also easier to write code that processes events.

    Distribute it to all PC's. Put it in the startup folder and have it launch when the user logs on. At startup, the program just has to minimize it's form. Basically, it's hides until there is a message to display.

    The program would periodically look for a message file that contains the text to be displayed. Maybe use a folder name like C:\ProgramData\MyMessages. You could do this with a file system watcher or or with a timer that wakes up every 30 seconds and looks for a message file, reads it, and copies it contents to a label on the form. After your program displays the message, it would delete the message file.

    https://www.codeproject.com/Articles/3192/Watching-Folder-Activity-in-VB-NET

    In your Invoke-Command code that runs on the individual PC's, all you have to do is create a file with your message in it.

    I'm sure that there are lots of ways to accomplish messaging. That was just one example.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.