We will have a quick look at the PowerShell start-sleep command let. It is used to pause the thread for a specified time. It is very useful in many situations and we use it in several of our tutorials on PowerShell.
This command let has an alias called sleep which is very useful.
In this post, we are going to see PowerSleep and few examples.
The PowerShell sleep is a simple command let as it has only two switches. The first switch is for seconds and the second switch is for milliseconds.
We can pass the number of seconds to the sleep switch as shown below.
We can use the sleep alias for the above command as shown below.
Clearly the alias makes it easy for us to use the command.
Next we will move on to using the millisecond switch. We can use the millisecond switch.
The milliseconds switch can be used with alias also as shown below.
Using the start-sleep with the alias for a millisecond helps us use the script easily.
The following script will show us how the start-sleep interferes with the execution of the code.
The above script will show the list of numbers instantaneously in a script that does not have the start-sleep option. Since we are using the start-sleep command let, we are able to write the numbers to the shell one after another after some delay.
In this post, we learned some of the least appreciated command lets called the start-sleep. The start-sleep command let can be replaced with the alias sleep. The start-sleep has two switches, one accepts the seconds of delay and another one accepts the milliseconds. Finally, we saw the use of the start-sleep on the loop to display a list of numbers.
If you want more awesome posts, stay tuned to TecKangaroo.
- Article Rating
- Content Relevance
- Content Clarity
- Author Rating