How to manage a debugging session

Before you start debugging, you must set one or more breakpoints. You cannot set a breakpoint unless the script that you want to debug is saved. For directions on of how to set a breakpoint, see How to manage breakpoints or Set-PSBreakpoint. After you start debugging, you cannot edit a script until you stop debugging. A script that has one or more breakpoints set is automatically saved before it is run.

To start debugging

Press F5 or, on the toolbar, click the Run Script icon, or on the Debug menu click Run/Continue. The script runs until it encounters the first breakpoint. It pauses operation there and highlights the line on which it paused.

To continue debugging

Press F5 or, on the toolbar, click the Run Script icon, or on the Debug menu, click Run/Continue or, in the Console Pane, type C and then press ENTER. This causes the script to continue running to the next breakpoint or to the end of the script if no further breakpoints are encountered.

To view the call stack

The call stack displays the current run location in the script. If the script is running in a function that was called by a different function, then that is represented in the display by additional rows in the output. The bottom-most row displays the original script and the line in it in which a function was called. The next line up shows that function and the line in it in which another function might have been called. The top-most row shows the current context of the current line on which the breakpoint is set.

While paused, to see the current call stack, press CTRL+SHIFT+D or, on the Debug menu, click Display Call Stack or, in the Console Pane, type K and then press ENTER.

To stop debugging

Press SHIFT-F5 or, on the Debug menu, click Stop Debugger, or, in the Console Pane, type Q and then press ENTER.

How to step over, step into, and step out while debugging

Stepping is the process of running one statement at a time. You can stop on a line of code, and examine the values of variables and the state of the system. The following table describes common debugging tasks such as stepping over, stepping into, and stepping out.

Debugging Task Description How to accomplish it in PowerShell ISE
Step Into Executes the current statement and then stops at the next statement. If the current statement is a function or script call, then the debugger steps into that function or script, otherwise it stops at the next statement. Press F11 or, on the Debug menu, click Step Into, or in the Console Pane, type S and press ENTER.
Step Over Executes the current statement and then stops at the next statement. If the current statement is a function or script call then the debugger executes the whole function or script, and it stops at the next statement after the function call. Press F10 or, on the Debug menu, click Step Over, or in the Console Pane, type V and press ENTER.
Step Out Steps out of the current function and up one level if the function is nested. If in the main body, the script is executed to the end, or to the next breakpoint. The skipped statements are executed, but not stepped through. Press SHIFT+F11, or on the Debug menu, click Step Out, or in the Console Pane, type O and press ENTER.
Continue Continues execution to the end, or to the next breakpoint. The skipped functions and invocations are executed, but not stepped through. Press F5 or, on the Debug menu, click Run/Continue, or in the Console Pane, type C and press ENTER.

How to display the values of variables while debugging

You can display the current values of variables in the script as you step through the code.

To display the values of standard variables

Use one of the following methods:

  • In the Script Pane, hover over the variable to display its value as a tool tip.

  • In the Console Pane, type the variable name and press ENTER.

All panes in ISE are always in the same scope. Therefore, while you are debugging a script, the commands that you type in the Console Pane run in script scope. This allows you to use the Console Pane to find the values of variables and call functions that are defined only in the script.

To display the values of automatic variables

You can use the preceding method to display the value of almost all variables while you are debugging a script. However, these methods do not work for the following automatic variables.

  • $_

  • $Input

  • $MyInvocation

  • $PSBoundParameters

  • $Args

If you try to display the value of any of these variables, you get the value of that variable for in an internal pipeline the debugger uses, not the value of the variable in the script. You can work around this for a few variables ($_, $Input, $MyInvocation, $PSBoundParameters, and $Args) by using the following method:

  1. In the script, assign the value of the automatic variable to a new variable.

  2. Display the value of the new variable, either by hovering over the new variable in the Script Pane, or by typing the new variable in the Console Pane.

转自:How to Debug Scripts in Windows PowerShell ISE

PowerShell 命令行调试指引(转)的更多相关文章

  1. 解决PowerShell命令行窗口中不显示光标的问题

    不知道什么原因,在有些系统上打开PowerShell命令行窗口后,光标无法显示.这种情况在Windows Server 2008/2012.Windows 8/9/10上都出现过,估计是由于某些系统软 ...

  2. linux命令行调试邮件服务器

    linux命令行调试邮件服务器 1. Linux客户端调试邮件过程 [root@mxtest ~]# telnet mail.xx.com 25 Trying 172.16.236.103... Co ...

  3. 【Windows10 IoT开发系列】Powershell命令行实用程序

    原文:[Windows10 IoT开发系列]Powershell命令行实用程序 更新帐户密码: 强烈建议你更新默认的管理员帐户密码.若要更新帐户密码,你可以发出以下命令: net user Admin ...

  4. 修改加粗cmd和powershell命令行的中文字体

    powershell 传教士 原创文章 2016-06-20 允许转载,但必须保留名字和出处,否则追究法律责任 ---[前言]--- 1 环境: win10 10586 powershell 5.0 ...

  5. 方法:怎么用ionic命令行调试你的ionic app

    官网上有很详细的解说  http://blog.ionic.io/live-reload-all-things-ionic-cli/ 下面说说我自己的调试过程(android版): 首先用命令行进入你 ...

  6. perl-cgi命令行调试

    来源: http://www.cnblogs.com/itech/archive/2012/09/23/2698838.html 参考: http://docstore.mik.ua/orelly/l ...

  7. 使用GDB命令行调试器调试C/C++程序

    原文:http://xmodulo.com/gdb-command-line-debugger.html作者: Adrien Brochard 没有调试器的情况下编写程序时最糟糕的状况是什么?编译时跪 ...

  8. 记录tiny6410 jlink 命令行调试linux-2.6.38内核

    1\首先启动nandflash uboot->linux内核->文件系统,进入文件系统命令行 2\启动JLinkGDBServer -device ARM11 3\启动arm-none-e ...

  9. 使用GDB命令行调试器调试C/C++程序【转】

    转自:https://linux.cn/article-4302-1.html 编译自:http://xmodulo.com/gdb-command-line-debugger.html作者: Adr ...

随机推荐

  1. vi 使用小结

    复制 1,ny 从哪行到哪行的复制,中间用逗号隔开,然后命令y. 黏贴 是在命令模式下直接按p即可 跳到n行: 命令模式直接输入数字即可 剪切:d命令 删除:x命令 跳到行首行尾:直接home或end ...

  2. linux中 bashrc文件的alias添加快捷命令

    alias (为了简化命令操作,节省时间) 进入 /home下的用户,假设为 web 执行命令 ls -alh   找到 .bashrc 隐藏文件,如果没有则新建 通过  vi .bashrc  在里 ...

  3. HashMap的实现原理,以及在JDK1.7和1.8的区别

    1.JDK1.7 HashMap是Java中大家最常用的一个map实现类,其为键值对也就是key-value的形式.他的数据结构则是采用的位桶和链表相结合的形式完成了,即拉链法.具体如下图所示: Ha ...

  4. 算术运算,赋值运算,if语句,while,continue语句

    算术运算 print(10 / 3)=3.333333333333 print(10 // 3)=3 print(10 ** 2)=100 赋值运算增量赋值 age=18 age+=1 print(a ...

  5. week06 12 我们准备数据 前端调用rpc 前后端联调一下

    用postman发送请求 出现一个问题 我在return结果前 要将数据转换成字典 所以我们用json.dumps()后再json.load()回来 这样就避免了这个问题 因为数据结构的数据 比如li ...

  6. 在阿里云Ubuntu 14.04 Linux服务器上安装docker

    参考 How To Install and Use Docker: Getting Started 这篇最靠谱的文档在阿里云 Ubuntu  14.04 服务器上成功安装 docker . ---- ...

  7. 把Gitlab迁移到Docker容器里

    把Gitlab迁移到Docker容器里 Apr 9, 2015. | By: 任怀林 公司的gitlab一直是运行在ovm的虚拟机里的,版本还是6.7.5.版本有点老了,最近在研究docker,于是想 ...

  8. python中安装request模块

    使用命令行(cmd)进入到python安装目录下的Scripts文件夹(也可以先进入目标文件夹然后在文件路径上打开cmd回车即可) 在命令行中输入pip install requests,等待安装完成 ...

  9. VMware虚拟机配置嵌套虚拟化

    VMware虚拟机下创建kvm-sever,server下继续创建kvm虚拟机(嵌套虚拟化),返回libvirt错误解决办法:SSH连接VMwarevi /etc/vmware/config增加一行设 ...

  10. Codeforces Round #437 E. Buy Low Sell High

    题意:买卖股票,给你n个数,你可以选择买进或者卖出或者什么都不做,问你最后获得的最大收益是多少. Examples Input 910 5 4 7 9 12 6 2 10 Output 20 Inpu ...