Forum Discussion

Tien Ngo Thanh's avatar
Tien Ngo Thanh
Iron Contributor
Feb 24, 2019

How to push message to all PC ?

Hello

      Please anyone guide me how to push message to all PC (Pc join domain) . I want when our system has problem then will push message to all pc to all user quick know .instead of when logon or send all email

Best Regards,

Thanks

     

  • Hello, there is a feature built in to windows that will do this!  The msg command on windows 10 or net send on windows 7 or older will accomplish this.  That being said its probably not as feature rich as you are going to want it! 

    Format of the command is

    MSG username /Server:Machinename "The Message you Want to Send"

    It presents a couple of issues for you as an administrator, including the fact that you have to know the list of machines on your network, have access to them via the MSG command (Basic Microsoft networking firewall access has to be enable at the domain level).

     

    The list of machines can easily be gotten if you have Powershell AD module loaded via

    (get-adcomputer -filter *).name

    If you don't have the Powershell Module you can use ADSI to enumerate your domain members via a searcher - 

    $Search = [adsisearcher]"(&(objectCategory=Computer))"

    ($search.findall()).properties.name > Computers.txt

    Edit the list to remove out unwanted machines, DC's etc

    The following code will enumerate the active logged on user

    ((qwinsta /server:$ServerName | foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)|where {$_.state -like "*ACTIVE*"}).username

    We could take this code from the TechNet  Community https://gallery.technet.microsoft.com/scriptcenter/Ping-Multiple-Computers-7d13a3aa

    And quickly modify it up so that if it pings the machine it sends the message

    Its not pretty and needs error handling and some fine tuning, possibly more logic as you require etc but

     

    $ServerName = Get-Content "c:\Temp\Computers.txt" 
    foreach ($Server in $ServerName) { 
            if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {  
             
                $Username=((qwinsta /server:$Server | foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)|where {$_.state -like "*ACTIVE*"}).username
      msg $username /Server:$Server "This is a system Broadcast"
             
                        } else 
                         
                        {"$Server not pinging" 
                 
                        }     
             
    }

     

    Should broadcast to all the machines active logged on users from a Windows 10 computer

  • Hello, there is a feature built in to windows that will do this!  The msg command on windows 10 or net send on windows 7 or older will accomplish this.  That being said its probably not as feature rich as you are going to want it! 

    Format of the command is

    MSG username /Server:Machinename "The Message you Want to Send"

    It presents a couple of issues for you as an administrator, including the fact that you have to know the list of machines on your network, have access to them via the MSG command (Basic Microsoft networking firewall access has to be enable at the domain level).

     

    The list of machines can easily be gotten if you have Powershell AD module loaded via

    (get-adcomputer -filter *).name

    If you don't have the Powershell Module you can use ADSI to enumerate your domain members via a searcher - 

    $Search = [adsisearcher]"(&(objectCategory=Computer))"

    ($search.findall()).properties.name > Computers.txt

    Edit the list to remove out unwanted machines, DC's etc

    The following code will enumerate the active logged on user

    ((qwinsta /server:$ServerName | foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)|where {$_.state -like "*ACTIVE*"}).username

    We could take this code from the TechNet  Community https://gallery.technet.microsoft.com/scriptcenter/Ping-Multiple-Computers-7d13a3aa

    And quickly modify it up so that if it pings the machine it sends the message

    Its not pretty and needs error handling and some fine tuning, possibly more logic as you require etc but

     

    $ServerName = Get-Content "c:\Temp\Computers.txt" 
    foreach ($Server in $ServerName) { 
            if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {  
             
                $Username=((qwinsta /server:$Server | foreach { (($_.trim() -replace "\s+",","))} | ConvertFrom-Csv)|where {$_.state -like "*ACTIVE*"}).username
      msg $username /Server:$Server "This is a system Broadcast"
             
                        } else 
                         
                        {"$Server not pinging" 
                 
                        }     
             
    }

     

    Should broadcast to all the machines active logged on users from a Windows 10 computer

    • Tien Ngo Thanh's avatar
      Tien Ngo Thanh
      Iron Contributor

      Hello

          This must open port from server to all PC ? is it show message as screenshot below ?

          

      • MurrayWallForte's avatar
        MurrayWallForte
        Iron Contributor

        The image that you have shown is an email sent out to all users, you could use a distribution group to do that, and as long as the users were logged in via email they would get that. 

        Maybe I didn't understand your ask correctly - you asked for a broadcast to all computers - What I wrote was a quick set of commands to broadcast to each computer whether it had outlook/email on it or not.  This shows up on the users screen no matter what is running and will not get recorded in the email system as this is completely independent of email, it does get recorded in the Computers Event Viewer that a message was sent - this broadcast is a message to the Active logged on user only on a domain computer only with no way for user feedback or acceptance- 

         

        This would used like a legacy paging system.  There are better ways to do this - commercial programs etc, but this broadcasts quick and dirty to all computers in the list of computers in your domain. 

        As long as you are an administrator and the machine you are broadcasting from is a domain connected computer, and all your computers don't have the windows firewall COMPLETELY locked down - this is not default - it should work to broadcast to the computers.