In Windows XP, this service was convenient though very picky which allowed sending messages to all PCs in the net sent * domain. “Message text!” But there were significant restrictions on the number of characters that could be written in the message. Very often the messages did not fit, but this is not the worst thing: Messages often did not reach because someone had the service disconnected from someone, it just stopped and if a person blocked the PC, he would not see the message before unlocking his station. As a result of the search, the next solution to this problem was born. We will use POWERSHELL. Its only drawback is that the message can only be sent by the administrator. This howto helps to send network popup message in Windows 7.
Displaying Notifications to Users Using PowerShell
Despite the fact that PowerShell is a console language, it is sometimes necessary to notify the user about a specific event or the need to perform a specific action from a PowerShell script. For example, to display a notification about the completion of a long-term PoSh script, or about the occurrence of some important event.
The easiest way to display a window with an arbitrary test through the Windows scripting subsystem is Wscript. The following code will display a plain text box with the required text and an OK button.
$wshell = New-Object -ComObject Wscript.Shell
$utput = $ wshell.Popup (“The report generation script is executed”)
/p>
Using various properties of the Popup method, you can customize the appearance of a modal message box. Including you can return to the script the results of the user’s response to the question (Yes / No).
$Output = $ wshell.Popup (“The report generation script is complete! Do you want to display it on the screen?”, 0, “Report is ready”, 4 + 32)
General syntax and parameters of the Popup method:
Popup(Text,SecondsToWait,Title,Type)
General syntax and parameters of the Popup method:
Popup(Text,SecondsToWait,Title,Type)
Options:
- Text — string, message text. SecondsToWait _optional number. The number of seconds after which the window will be automatically closed. Title — optional string. The text of the message box title. Type — optional number. The combination of flags determines the type of buttons and icon. Possible flag values:
- 0 — OK button.
- 1 — OK and Cancel buttons.
- 2 — buttons Stop, Repeat, Skip.
- 3 — buttons Yes, No, Cancel.
- 4 — Yes and No buttons.
- 5 — buttons Repeat and Cancel.
- 16 — Stop icon.
- 32 — Question icon.
- 48 — Exclamation icon.
- 64 — Information icon.
More attractive and pleasant looking pop-up messages (ballons) can be displayed in Windows 7, 8.1 and 10 through the Windows Forms API. The following PowerShell code will display a pop-up message next to the Windows 10 notification bar, which will automatically disappear after 10 seconds.
Add-Type -AssemblyName System.Windows.Forms
$ global: balmsg = New-Object System.Windows.Forms.NotifyIcon
$ path = (Get-Process -id $ pid) .Path
$ balmsg.Icon = [System.Drawing.Icon] :: ExtractAssociatedIcon ($ path)
$ balmsg.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon] ::
$ balmsg.BalloonTipText = ‘This is the text of the pop-up message for the Windows 10 user.’
$ balmsg.BalloonTipTitle = “Warning $ Env: USERNAME”
$ balmsg.Visible = $ true
$ balmsg.ShowBalloonTip (10,000)
In addition to create colorful pop-up messages in Windows 10 (PowerShell 5.0+), you can use the separate PowerShell module BurntToast from the PowerShell gallery.
The module is installed from the online repository using the Windows 10 package manager:
Install-Module -Name BurntToast
Script for Sending Messages on Windows
Try to use this Powershell script
#options
param (
$ message = (Read-Host -Prompt “Enter the message text to send:”)
)
$ cComps = @ ()
$ OnlinePC = @ ()
$ OfflinePC = @ ()
# Create process variable with parameters
$ Proc = “msg.exe -v -time: 90000 * $ message”
# Getting All PCs from AD
$ cComps = GET-QADcomputer | % {$ _. Name}
Write-Host “Check the availability of PC, please wait …` t ”-NoNewline
$ cComps | Sort-Object name | % {
$ name = $ _
if (test-connection-computer $ name -quiet -Count 1) {$ OnlinePC + = $ name}
else {if (test-connection-computer $ name -quiet) {$ OnlinePC + = $ name} $ OfflinePC + = $ name}
}
Write-Host “Done!”
Write-Host “ON line PC:” $ OnlinePC.Count
Write-Host “OFF line PC:” $ OfflinePC.Count -ForegroundColor red
$ OnlinePC | % {
([WMICLASS] “\\ $ _ \ Root \ CimV2: Win32_Process”). Create ($ Proc) | Out-null
if ($?) {“Message to $ _ sent”} else {Write-Host “On $ _ problems sending a message” -BackgroundColor Black -ForegroundColor Red}
}
$ OfflinePC | % {
Write-Host $ _ “OFF Line” -BackgroundColor Red -ForegroundColor Black
}
Consider Using Action1 to Send Network Popup Message if:
- You need to perform an action on multiple computers simultaneously.
- You have remote employees with computers not connected to your corporate network.
Action1 is a cloud-based platform for patch management, software deployment, remote desktop, software/hardware inventory, endpoint management and endpoint configuration reporting.