How to stop a long running cmdlet in PowerShell

10,479

Solution 1

Hit Ctrl + C to break the cmdlet in process, returning you to the C: prompt.

Ctrl + C

Solution 2

This depends on the environment you are working in.

Ctrl + C works in the PowerShell console and ISE. I use the PowerGUI script editor and to achieve the same I use Shift + F5.

Share:
10,479
AymenDaoudi
Author by

AymenDaoudi

Updated on June 14, 2022

Comments

  • AymenDaoudi
    AymenDaoudi almost 2 years

    Let's say I run this cmdelt :

    C:\> Get-EventLog Application
    

    This cmdlet takes forever showing events and never stops, is there a certain command or something I can type to stop it and return to my C:\> ?

  • orion elenzil
    orion elenzil almost 2 years
    Ctrl + C often fails to interrupt commands. For example, Get-FileHash -Algorithm MD5 -Path '<some large file on network storage>'. The key-combo does work, but it takes maybe two minutes.