# How to set the line breakpoint in the PowerShell?

PowerShellMicrosoft TechnologiesSoftware & Coding

To set the line breakpoint in the script, we can use the Set-PSBreakpoint command with -Line parameter and need to give the path of the script on which the Line breakpoint needs to set.

Consider we have the script below which retrieves the value up to 99, starting from 1,

We will set the Line Breakpoint at line number 3 so we will use the below command. Here the script name is WhieScript.ps1 and stored at C:\temp.

Set-PSBreakpoint C:\temp\WhileScript.ps1 -Line 3

Once you run the above command, you will get the output with the details as shown below.

ID Script    Line Command Variable Action
-- ------   ---- ------- -------- ------
6 WhileScript.ps1 3

To check all the applied breakpoints, you can use the Get-PSBreakPoint command.

Now to enter the debug mode, you need to run the script.

You can see in the above image that the console has entered debug mode. To continue till the next breakpoint, press ‘C’.

There are other keywords for step in, step out, exit, etc. You can check them below at the MS site.