PowerShell for Windows Admins

Jan 31 2019   8:34AM GMT

Start-Sleep change

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

Start-Sleep change in PowerShell v6.2 preview 4

Start-Sleep has had this syntax

Start-Sleep [-Seconds] <int> [<CommonParameters>]

Start-Sleep -Milliseconds <int> [<CommonParameters>]

 

since it was first introduced in PowerShell v1 (I think).

You can define the period as a number of seconds or use the –Milliseconds option if you need a fraction of a second.

In PowerShell v6.2 preview 4 this changes to

Start-Sleep [-Seconds] <double> [<CommonParameters>]

Start-Sleep -Milliseconds <int> [<CommonParameters>]

 

so you can use

Start-Sleep -Seconds 3.5

 

If you try the command in Windows PowerShell v5.1 or PowerShell v6.1 it will work but I suspect that the 3.5 is converted to an integer so you don’t get the correct delay.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: