windowspowershellmessagebox

msg.exe prints "Invalid parameter(s)"


I am working on a small server monitoring script, and want to show a pop-up window to the user with a list of services once they are detected to be down. I tried sending this message with C:\Windows\SysWOW64\msg.exe but it just gives me a mysterious error message in the PowerShell terminal ("Invalid parameter(s)", I thought I maybe had special characters or bad data types, but that is not the case):

PS U:\> msg * ("A" * 256)
Invalid parameter(s)
Send a message to a user.

MSG {username | sessionname | sessionid | @filename | *}
    [/SERVER:servername] [/TIME:seconds] [/V] [/W] [message]

Solution

  • msg.exe apparently only supports messages <= 255 characters in length. Use Popup instead:

    (New-Object -ComObject "Wscript.Shell").Popup("Popup Message", 0, "Popup Title", 0+48)