Make a script to answer an command dos : msg

Welcome Forums General PowerShell Q&A Make a script to answer an command dos : msg

This topic contains 7 replies, has 3 voices, and was last updated by

 
Participant
2 months, 3 weeks ago.

  • Author
    Posts
  • #162569

    Participant
    Topics: 1
    Replies: 2
    Points: -1
    Rank: Member

    Hello,

    Currently, I have made an automated script to send an msg command to a target group in the AD.

    I would like to know if it was possible to get an answer when the customer receives the popup except for the /W argument of the MSG command.

    For my script, I use Get-ADComputer & Invoke-WmiMethod to check IP list and send same text at all customer list.

    Thx,

  • #162633

    Participant
    Topics: 2
    Replies: 54
    Points: 278
    Helping Hand
    Rank: Contributor

    What do you mean by 'get an answer'? Do you want the user to be able to send a message back to you? It can't do that, it's not a chat system.

    However, if you just want to receive an automatic message to tell you when the user has clicked OK, you can add the /V flag.

  • #162726

    Participant
    Topics: 1
    Replies: 2
    Points: -1
    Rank: Member

    The problem with /W is that it launches itself on the target's computer,

    so I have no return on my Powershell,

    so I can't know if the target computer received it or not.

    (sorry for my poor knowledge of English)

    • #162737

      Participant
      Topics: 0
      Replies: 15
      Points: 61
      Helping Hand
      Rank: Member
    • #162785

      Participant
      Topics: 2
      Replies: 54
      Points: 278
      Helping Hand
      Rank: Contributor

      Ok, so try using MSG like this:

      MSG * /SERVER:computername /V /W "test message"

      Use both /V and /W at the same time. Set computername to be the target computer.
      The /V flag is for Verbose mode, which will output messages to your PowerShell terminal.

      When you execute the command, you should immediately see the message

      Sending message to session Console, display time 60

      This indicates that the message was sent to the target computer.

      When the user clicks the OK button, you should see the message

      Message to session Console responded to by user

      This indicates that the user clicked the button in the message box. However, if the time limit runs out the message box will close and you will receive the same message in your terminal, so this could happen even if the user did not see the message. If you want the message box to not have a time limit, but stay displayed until the user clicks OK, set /TIME:0 like this:

      MSG * /SERVER:computername /TIME:0 /V /W "test message"

      Also if the target computer is offline, you will receive an error message that looks like this:

      Error 1722 getting session names

      This indicates that the target computer could not be found on the network.

  • #162866

    Participant
    Topics: 1
    Replies: 2
    Points: -1
    Rank: Member

    rejikodiyil : Yeah, i've search something like this and i found this :https://github.com/Windos/BurntToast/ and make this : https://github.com/Eperrial/PowerShell-Remote-Message-

    But, this module can be only work on remote client, because i can't sent my script and the module all time, however, How can i do send some action to remote client and active my script that contains my popup ??

     

    grokkit : I didn't know this item works like this, thanks for this tutorial... But i think it doesn't working with multiple remote client ( like an list IP) or i can't send all message at the same time : x

     

    • #163122

      Participant
      Topics: 0
      Replies: 15
      Points: 61
      Helping Hand
      Rank: Member

      In my scenario, everything runs on my scripting server (windows 2012) and whenever I require an interaction with end user, I invoke only message sending code into the remote machine and waits for the exit code in server (it could be button click or a timeout). Resumes the actual script in server once invoke command returns the exit code. All my modules and scripts are inside my server and I am not sending anything to remote machine.

  • #162896

    Participant
    Topics: 2
    Replies: 54
    Points: 278
    Helping Hand
    Rank: Contributor

    But i think it doesn't working with multiple remote client ( like an list IP) or i can't send all message at the same time

    Yes. Does your script use a foreach loop to send a message to each computer in your AD group?

    If so, the issue is that with /W applied, MSG will wait for a response from each computer before continuing to the next one in the list, which will be a problem if any of them are idle.

    Take a look at this script, it may give you what you want.

You must be logged in to reply to this topic.