SID-500

Home » Windows Server » Active Directory: Send Messages to all currently logged on Users (msg.exe)

Active Directory: Send Messages to all currently logged on Users (msg.exe)

Do you remember the net send command? And do you remember the security concerns? Last week I played with msg.exe. Msg is the “new” net send. I tried to send a message to all users and computers in my domain. Why? I wanted to instruct all users to close all open programs. And now I want to keep and share this knowledge in form of this blog post.

Introduction (msg.exe)

Msg sends a message to a user. This user must be logged in as a domain user (Domain Profile). Which means that the following only works in a domain environment. For network technicans: msg uses Port 445 (SMB/CIFS). If you send a message to a user you have to provide a computername and a username. Or you can try sending a message to yourself:

msg * "Hallo, this is a test!"

1.PNG

* means, that the message is send to all logged on users. Keep in mind that Windows is a multi-user operating system. Don’t forget the others! 😉

Prerequisites

The headline is somewhat misleading. Yes, we are going to send messages to all users, but actually to all computers. Suppose all your client computers are stored in specific Organizational Unit called Workstations. You want to inform all users logged on to this computers. I am going to use Invoke-Command. Make sure, your client computers accepts Remote PowerShell commands. You can run Enable-PSRemoting on each of them. Or you could configure WinRM by using Group Policies:

https://social.technet.microsoft.com/wiki/contents/articles/33634.enable-powershell-remoting-via-group-policy-on-windows7windows-server-2008-r2.aspx

Summary

  • All Computers must reside in the same domain
  • WinRM has to be enabled on the client computers by running Enable-PSRemoting or by configuring via Group Policies. Note that on Windows Server 2012/2016 operating systems WinRM is enabled by default, but not on Windows Client systems.

Sending Messages to all Users: PowerShell and Msg.exe in Action

The following One-Liner gets all the computernames of the OU Workstations in the domain sid-500.com. Afterwards msg is executed for each computer in the OU Workstations. The message is send to all users which are currently logged on.

(Get-ADComputer -SearchBase "OU=Workstations,DC=sid-500,DC=com" -Filter *).Name | Foreach-Object {Invoke-Command -ComputerName $_ {msg * "Please close all open files. The Server will be shut down in 5 Minutes"}}

1.PNG

Client01 is a member of the OU Workstation. Client01 receives the message.

1.PNG

Have fun playing with msg!

See also

For more remote actions see also:

PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk)

PowerShell: Using Restart-Computer to restart your Computer and Remote Computers


3 Comments

  1. […] Active Directory: Send Messages to all currently logged on Users (msg.exe) […]

    Like

  2. Rich says:

    Really enjoying reading your blog posts. And your new linked group.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

WHOIS

My name is Patrick Grünauer (pewa2303). I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Patrick Gruenauer
Follow SID-500 on WordPress.com