PowerShell tutorial – exploring Start-Sleep CMDLET

Hi All,

Greetings for the day!!! Continuing the PowerShell tutorial

Today exploring one of the important CMDLET – Start-Sleep

Details / Use Case

  • In one of the my application I was executing PowerShell script against SharePoint online
  • PowerShell script was containing CMDLETs from SharePoint online module and looping through site collections
  • Suddenly script started throwing and 429 error – Too Many Requests
  • This means we are getting throttled in SharePoint online
  • So the CMDLET Start-Sleep came to rescue 🙂

SharePoint Online uses throttling to maintain optimal performance and reliability of the SharePoint Online service. Throttling limits the number of API calls or operations within a time window to prevent overuse of resources


Start-Sleep -Seconds <int>

Start-Sleep -Milliseconds <int>

fig : PowerShell Tutorial - exploring "Start-Sleep" CMDLET
fig : PowerShell Tutorial – exploring “Start-Sleep” CMDLET
  • The Start-Sleep cmdlet suspends the activity in a script or session for the specified period of time
  • We can use it for many tasks, such as waiting for an operation to complete or pausing before repeating an operation
  • In my PowerShell script I used this CMDLET – Start-Sleep in between SharePoint online CMDLETs and 429 error resolved


  • Example 1 – Demonstrating pause of 2 seconds in between two CMDLETs
#getting current time
$currentTime = Get-Date -DisplayHint Time

Write-Host "Current time is - " $currentTime
Write-Host lets wait for 2 seconds

#pausing for 2 seconds
Start-Sleep -Seconds 2

#getting time after 2 seconds
$timeAfter2Secs = Get-Date -DisplayHint Time

Write-Host "After waiting 2 secs time is - " $timeAfter2Secs

Output : 

Current time is -  9/2/2023 11:35:34 PM

lets wait for 2 seconds

After waiting 2 secs time is -  9/2/2023 11:35:36 PM

fig : PowerShell Tutorial - exploring "Start-Sleep" CMDLET
fig : PowerShell Tutorial – exploring “Start-Sleep” CMDLET


Thanks for reading! If you think this is useful, kindly please like and share! HAVE a FANTASTIC LEARNING ! LIFE IS BEAUTIFUL 🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: