Looping an Entire PowerShell Script

Welcome Forums General PowerShell Q&A Looping an Entire PowerShell Script

Viewing 7 reply threads
  • Author
    Posts
    • #262805
      Participant
      Topics: 13
      Replies: 40
      Points: 177
      Rank: Participant

      Is it possible to get a PowerShell Script to keep looping and repeating the same code indefinitely until terminated with something like a Control – C Keystroke?

      I was thinking of something like a Do While Loop but need a little direction here with, hopefully some sample code as well.

      Thank you all so much for the wonderful responses thus far. God bless you all!!!

    • #262901
      Participant
      Topics: 1
      Replies: 342
      Points: 326
      Helping Hand
      Rank: Contributor

      You’re thinking along the right lines.  At its most basic it would be:

    • #262934
      Participant
      Topics: 13
      Replies: 40
      Points: 177
      Rank: Participant

      Thank you for the reply Matt.

      May I ask what the code would look like beyond its most basic?   Samples please?

       

      Thank you and God bless you Sir!!!

    • #262940
      Participant
      Topics: 1
      Replies: 342
      Points: 326
      Helping Hand
      Rank: Contributor

      Well it’s really just a case of replacing the #Loop forever comment with your own code.  How about a talking clock?

       

    • #262955
      Participant
      Topics: 13
      Replies: 40
      Points: 177
      Rank: Participant

      Sweet Matt!!!

      I just tested it.

      Its perfect. I think I will only need the core component but your example definitely illustrates the point clearly.

      Thank you Sir and have a blessed day!!!

    • #263957
      Participant
      Topics: 13
      Replies: 40
      Points: 177
      Rank: Participant

      Let me ask you this Matt:

      How would you get that particular script you wrote to go off at the quarter mark, (15, 30, 45, top of the hour), of every hour in the day continuously?

    • #263969
      Participant
      Topics: 1
      Replies: 342
      Points: 326
      Helping Hand
      Rank: Contributor

      For a requirement like that, I would use a scheduled task.

    • #263987
      Participant
      Topics: 13
      Replies: 40
      Points: 177
      Rank: Participant

      My thoughts exactly. Thank you

Viewing 7 reply threads
  • You must be logged in to reply to this topic.