powershell sleep time

Posted on 2012-08-23
Last Modified: 2012-08-23
i am new to powershell and hoping I can get some assistance. i am running this script to power down machines during a UPS power failure. How can I put in a sleeptime between each machine in the server.txt file. I have a particular order all machines need to power off

$psSwitches = ” -s -f -c -t 30?"

$strComputer = get-content “Servers.txt”
$application = “psshutdown.exe”
Foreach ($i in $strComputer)
    $arguments = “\\$i” + $psSwitches + $psMessage
    # write-host $arguments
Question by:progjm
    LVL 16

    Accepted Solution

    You can try adding the below command within the Foreach loop.

    Start-Sleep -s 10

    This will pause Windows Powershell for 10 seconds.
    LVL 1

    Author Comment


    I will give it a shot here in a bit
    LVL 67

    Expert Comment

    BTW, you do not need to use [System.Diagnostics.Process]::start for those calls. psshutdown (and almost all other external commands) can be run directly:
    gc “Servers.txt” | % {
      psshutdown \\$_ -s -f -c -t 30
      start-sleep -s 10

    Open in new window

    LVL 1

    Author Comment

    Sorry Qlemo saw your add after i accepted a solution, but thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now