none
PowerShell Broadcast RRS feed

  • Question

  • Hey Scripting Guy, I have written a PowerShell utility that will use MSG.EXE to display a message to Windows 7 machines.  This utility will read a .TXT file and this .TXT file has about 1,500 machine names inside of it.   Some are online some are not so it does a Test-Connection -count 1 on each.   Our issue is this runs 1 machine at a time so it takes a very long time to complete.   How do I make PowerShell send to a large chunk of machines at once?  Example:  Can PowerShell read the first 250-500 lines of this .TXT file at once and send the MSG.EXE message to all 250-500?  

    Thank you.  


    mqh7

    Wednesday, November 2, 2016 4:42 PM

Answers

  • get-command *workflow*

    Be sure you have installed workflow support in WS2016.


    \_(ツ)_/


    • Edited by jrv Saturday, November 5, 2016 4:26 PM
    • Marked as answer by mqh7 Sunday, November 6, 2016 2:28 AM
    Saturday, November 5, 2016 4:26 PM

All replies

  • Use a PowerShell workflow:

    help about_workflows


    \_(ツ)_/

    Wednesday, November 2, 2016 5:10 PM
  • The help for PowerShell workflows, about_workflows:

    https://technet.microsoft.com/en-us/library/jj149010.aspx

    which refers to this reference:

    https://technet.microsoft.com/en-us/library/jj134242.aspx


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Thursday, November 3, 2016 12:41 AM
    Moderator
  • What about multi threading?  Can that do the same thing?   The whole "workflow" method is beyond my level of programming.   That is for a true developer, I'm a SysAdmin looking for a hack ;-)


    mqh7

    Thursday, November 3, 2016 1:37 PM
  • You could use powershell jobs to do the multithreading. I wrote a blog on this some time ago. http://sonnypuijk.nl/wp/powershell-jobs-for-multithreading/

    Thursday, November 3, 2016 1:39 PM
  • Jobs are harder to manage.  Workflow is multi threading.  Jobs are NOT multi-threading they are separate processes.

    You can use easier.  Workflow is easy./

    Workflow Send-BroadcastMsg{
         foreach -parallel ($computers in $computers{
               #code
        }
    }

    https://technet.microsoft.com/en-us/library/jj574157(v=ws.11).aspx


    \_(ツ)_/


    • Edited by jrv Thursday, November 3, 2016 4:00 PM
    Thursday, November 3, 2016 4:00 PM
  • ok, here is my total ignorance.   can I write the Workflow within PowerShell ISE or do I need a whole different development studio for this?    In ISE I run get-command w* and I see nothing for workflows.   

    mqh7

    Thursday, November 3, 2016 8:21 PM
  • Start by running the first command that jrv posted.


    PS C:\> help about_Workflows

    Requires Windows PowerShell 3.0 or newer.

    -- Bill Stewart [Bill_Stewart]

    Thursday, November 3, 2016 8:25 PM
    Moderator
  • Hello.  I am running PowerShell 5.1   when I type Get-Command -CommandType Workflow  it returns nothing.    running New-PSWorkflowSession returns that it is not a known cmdlet.    so how do I run/use workflows?  


    mqh7

    Saturday, November 5, 2016 4:20 PM
  • get-command *workflow*

    Be sure you have installed workflow support in WS2016.


    \_(ツ)_/


    • Edited by jrv Saturday, November 5, 2016 4:26 PM
    • Marked as answer by mqh7 Sunday, November 6, 2016 2:28 AM
    Saturday, November 5, 2016 4:26 PM