- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use the Timeout command in PowerShell?
Timeout.exe is actually a cmd command which can also be used in PowerShell. Let see the help related to Timeout command.
If we see the timeout parameters list we can use /T which indicates the Time in seconds and /NoBreak command, which Ignores any key for the specified time.
Write-Output "Timeout is for 10 seconds" Timeout /T 10 Write-Output "This line will be executed after 10 seconds if not interuptted"
PS C:\> C:\Temp\TestPS1.ps1 Timeout is for 10 seconds Waiting for 5 seconds, press a key to continue ...
Please note: In the above example, the user can interrupt the timeout seconds using any key to disallow the user interruption use /NoBreak Switch.
Write-Output "Timeout is for 10 seconds" Timeout /NoBreak 10 Write-Output "This line will be executed after 10 seconds"
PS C:\> C:\Temp\TestPS1.ps1 Timeout is for 10 seconds Waiting for 2 seconds, press CTRL+C to quit ...
If you enter the Ctrl+C, it will terminate the entire script execution.
- Related Articles
- How to use the tree command in PowerShell?
- How to use –Timeout parameter in Restart-Computer cmdlet in PowerShell?
- How to use the Set-Location command in PowerShell?
- How to use Split-Path command in PowerShell?
- How to use the ConvertFrom-StringData command in PowerShell?\n
- How to use PowerShell Break statement with the Switch command?
- How to use Push-Location and Pop-Location command in PowerShell?
- How to Run a Command with Time Limit (Timeout) In Linux
- What is the use of Get-Process command in PowerShell?
- How to run Invoke-Command in PowerShell Workflow?
- How to convert command output to the Hashtable format in PowerShell?
- How to get/resolve the command from the alias in PowerShell?
- How to run PowerShell commands from the command prompt?
- How to pass arguments in Invoke-Command in PowerShell?
- How to run a PowerShell script from the command prompt?