从ISE控制台运行的Powershell脚本似乎没有结束

从ISE控制台运行的Powershell脚本似乎没有结束,powershell,debugging,Powershell,Debugging,我是Powershell和ISE的新手,所以不确定我做错了什么 当我从Powershell ISE中执行以下脚本时,它会运行,并获得正确的输出,但调试器仍在运行。状态显示: “正在运行脚本/选择。按Ctrl+Break可停止。按Ctrl+B可进入调试器。” Ctrl+B似乎什么都不做。 点击Ctrl+Break后,状态显示“停止”。此时,所有调试选项都将灰显。我可以编辑和保存脚本,但无法再次运行它(或任何其他脚本)。此时我所能做的就是关闭并重新启动Powershell ISE 多谢各位 nets

我是Powershell和ISE的新手,所以不确定我做错了什么

当我从Powershell ISE中执行以下脚本时,它会运行,并获得正确的输出,但调试器仍在运行。状态显示: “正在运行脚本/选择。按Ctrl+Break可停止。按Ctrl+B可进入调试器。”

Ctrl+B似乎什么都不做。 点击Ctrl+Break后,状态显示“停止”。此时,所有调试选项都将灰显。我可以编辑和保存脚本,但无法再次运行它(或任何其他脚本)。此时我所能做的就是关闭并重新启动Powershell ISE

多谢各位

netsh wlan show profiles
#
Add-Type -AssemblyName Microsoft.VisualBasic
$ProfileName = [Microsoft.VisualBasic.Interaction]::InputBox('Enter Profile name', 'Thing to find', 'WiMyFi')
#
 If ($ProfileName) {
  $Output = netsh.exe wlan show profiles name= $ProfileName key=clear
  #
  Echo $Output
  #
  $SSID = $Output | Select-String -Pattern 'SSID Name'
  $SSID = ($SSID -split ":")[-1].Trim() -replace '"'
  #
  $PW = $Output | Select-String -Pattern 'Key Content'
  $PW = ($PW -split ":")[-1].Trim() -replace '"'

  Write-host 'SSID:' $SSID ', Password:' $PW
  }

使用VisualBasic,您需要在字符串上使用双引号
而不是单引号

试一试

见:

如果我添加:开始睡眠-秒1

之后:添加类型-AssemblyName Microsoft.VisualBasic

之前:$ProfileName=[Microsoft.VisualBasic.Interaction]::InputBox('Enter Profile name','Thing to find','WiMyFi')


然后脚本会运行。如图所示!

您为什么使用ISE而不是像Visual Studio代码这样更成熟的编辑器?众所周知,ISE的行为可能与预期的不同。您是否在powershell.exe控制台中看到同样的问题?我注意到脚本实际上没有在ISE上运行。它正在挂起:$ProfileName=[Microsoft.VisualBasic.Interaction]::InputBox('Enter Profile name'、'Thing to find'、'WiMyFi')。是否有需要加载的模块?它可以从powershell.exe运行。感谢您的建议,Theo,但这似乎没有什么不同。脚本在$ProfileName=…@ModelsRUs处仍然失败。您确定吗?对我来说(powershell 5.1)它与单引号挂起。当我使用所有双引号时,没有问题。希望我能缩小这个问题的范围。当我逐步阅读代码时,$ProfileName=语句似乎有效,但当我尝试整体运行它(F5)时失败。我想你应该奖励@VictorWolf至少一次向上投票。
$ProfileName = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Profile name", "Thing to find", "WiMyFi")