dev
dev

Reputation: 961

PowerShell command tracing

I have worked and created many script in UNIX but I am new to PowerShell and looking for some help as the world knows stackoverflow is best for this.

Now we know

sh -x script_name.sh

runs a shell script in interactive mode and display commands line by line as they are executed.

CAN THIS BE DONE IN POWERSHELL ?

I want PowerShell script to executed in Interactive mode

.\Script_name.ps1 just simply executes it. Please help.

Upvotes: -1

Views: 4663

Answers (2)

Arpit
Arpit

Reputation: 6260

You can use powershell debugging cmdlets to achieve this. You need to add a break-points.

Available cmdlets are:

 - New-PsBreakpoint
 - Get-PsBreakpoint
 - Enable-PsBreakpoint
 - Disable-PsBreakpoint
 - Remove-PsBreakpoint
 - Step-Into
 - Step-Out

Setting a break-point is as simple as:-

New-PSBreakpoint -script .\Script_name.ps1 -line 4

Refer this document for further details

Upvotes: 0

vonPryz
vonPryz

Reputation: 24071

Use Set-PSDebug cmdlet to set debug features on or off. For example, set-psdebug -trace 0 will disable tracing and set-psdebug -trace 2 will trace in very verbose a mode.

Upvotes: 2

Related Questions