In my daily work, there are times which I need to contact a user who is using a particular PC, but they don’t respond. Mostly, I need to contact them to inform about something, or get them to reboot, or install something etc. There are some cases which it is not possible, such as :
- They use a generic account which is shared, so we can’t find who exactly is using that PC
- They are logged off from IM
- They don’t respond to IM or just ignore them.
In these kind of cases, it is easier if we have some way to forcefully push a message to the PC. I found an easy solution from internet that can do this in every computer that you have admin access.
Open a text editor and add the following in it, then save it with .ps1 extension.
Function remote_message{ $server = read-host -prompt 'Input PC name'; $message = read-host -prompt 'Enter the message'; Invoke-WmiMethod -Class win32_process -ComputerName $server -Name create -ArgumentList "c:\windows\system32\msg.exe * $message" } remote_message
To run this, open powershell, then navigate to the saved location and run. And follow the input prompt.
No matter who is logged in the remote PC, they will get the message pop up on top of all their windows.
Edit 30/07/2019 :
This is one of the first powershell script that I ever wrote. Now having quite a bit of experience with powershell, I think that this is not the best way of doing it. Nevertheless as I mentioned multiple times before, it works.