run script after x time

Welcome Forums General PowerShell Q&A run script after x time

Viewing 7 reply threads
  • Author
    Posts
    • #229138
      Participant
      Topics: 41
      Replies: 94
      Points: 560
      Rank: Major Contributor

      Hi
      I’ve this piece of code and I wonder what’s the best way using a do while or a do until

      also I want to see an update every 60 sec once the 30 min have passed I want to execute my script

      Paul

    • #229183
      Participant
      Topics: 12
      Replies: 527
      Points: 1,247
      Helping Hand
      Rank: Community Hero

      What this will do is:
      – If the last dir sync was over 30 min ago, invokes checks.ps1
      – Runs indefinitely, checks last sync every 60 sec

    • #229198
      Participant
      Topics: 41
      Replies: 94
      Points: 560
      Rank: Major Contributor

      Hi Sam,

      thanks for your help,

      I have several scripts to perform the offboarding process
      1 that runs directly on AD on Premises, does the actual disabling account along with several other things
      2. moving over to AZure Ad and remove all the groups a user is member of. this can only be done when the 30 min have passed
      at this very moment it says last time synced is 4 min ago.
      this means that the script under point 2 needs to wait at least 26 min before I can execute that script once executed this piece of code needs to stop checking till the next time it’s being used

      what do I need to do in order to get it working like this?

      Paul

       

    • #229204
      Participant
      Topics: 8
      Replies: 562
      Points: 2,149
      Helping Hand
      Rank: Community Hero

      Start-sleep -Seconds 1560 ??

    • #229210
      Participant
      Topics: 41
      Replies: 94
      Points: 560
      Rank: Major Contributor

      Hi Doug,

      fair enough but would like to have this automated then how do I do this?

    • #229213
      Participant
      Topics: 12
      Replies: 527
      Points: 1,247
      Helping Hand
      Rank: Community Hero

      what do I need to do in order to get it working like this?

      uhm, nothing. Sit tight for 26 more minutes, lol

      this piece of code needs to stop checking till the next time it’s being used

      why?
      but if you must: CTRL-C

    • #229219
      Participant
      Topics: 12
      Replies: 527
      Points: 1,247
      Helping Hand
      Rank: Community Hero

      acer460527, the purpose of this forum is to help people understand PowerShell. You’re expected to demonstrate that you understand the code posted. If not, you’re expected to ask about any portion of the code that you don’t understand.

    • #229237
      Participant
      Topics: 41
      Replies: 94
      Points: 560
      Rank: Major Contributor

      Sam,

      thanks for your Reaction I understand that your code runs non stop unless I hit stop code or ctrl c as you say.
      I’m still learning and each time struggling with do while or do until or do and while alone

      I’ll be happy to learn

      Paul

       

Viewing 7 reply threads
  • The topic ‘run script after x time’ is closed to new replies.