Naming each server and adding timeout with invoke command RRS feed

  • Question

  • Hi there,  

    I am new to the site, and was wandering if you could help a newbie with his query :)

    So i have a list of 8 remote servers (on the same domain), all of which I want to restart their IIS service. So far I have come to this:

    #listing all fsapi servers
    $Servers = @("server1","server2","server3","server4","server5","server6","server7","server8") 

     ForEach($server in $Servers){
         Invoke-Command -ComputerName $server -ScriptBlock {
             iisreset /restart

    Now my addons that I would like to add to my script are:

    1) Name each an every server while script is running example:

    "Server1 IIS restarting"

    Attempting stop...

    Internet services successfully stopped

    Attempting start...

    Internet services successfully restarted

    2) Add a timeout of 120 seconds in the script for each and every server while script is running

    All of your output is appreciated guys :)



    • Edited by malccami Sunday, June 3, 2018 3:08 PM
    Sunday, June 3, 2018 3:06 PM

All replies