3

I'm not sure if I'm being a bit thick, but I have a simple script with three lines:

$iis = 90000
$name = "somesite"
Write-Host("Values are: $iis and $name")

If I set a breakpoint on any of these lines and hit the play button (F5 - start debugging) the script runs but the breakpoints are ignored.

If I start the script with F11 (step into) I can step through just fine, however hitting F5 to run to the next breakpoint again causes PowerGUI to ignore the breakpoints

The script I'm working on is substantial and I don't really want to have to F11 through every line of code.

Why would this be?

  • I'm running PowerGUI 2.2.0.1358 on Windows 7 64-bit Ultimate Edition.
  • I tried both the x64 and x32 versions of the PowerGUI script editor without success.
  • I'm also running the PowerGUI Script Editor as Administrator (launched using right-click on PowerGUI Script Editor shortcut and Run As Administrator)
  • My PowerShell execution policy is set to Unrestricted.
Kev
  • 118,037
  • 53
  • 300
  • 385
  • 1
    Not sure about PowerGUI but with ISE you have to save the file before you can debug with breakpoints. That is, the breakpoints are set on script paths and not unnamed/unsaved code sitting in an editor buffer. – Keith Hill Dec 06 '10 at 16:19
  • @Keith - I fell back to PowerShell ISE but it won't let me set breakpoints if I run as Administrator: http://stackoverflow.com/questions/4368612 . – Kev Dec 06 '10 at 16:29

3 Answers3

2

I had this problem when the script that I was running was on a remote file share. E.g. \\serverA\FileShare\script.ps1.

When I saved the script as c:\script\script.ps1 it was ok.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
pietje
  • 21
  • 1
  • For that matter, an unsaved file like 'untitled.ps1' doesn't seem to like hitting breakpoints until you've minimally saved it somewhere. – KyleMit Aug 12 '15 at 15:08
2

It looks like there's a problem with PowerShell and square brackets in folder and filenames.

Both PowerGUI and PowerShell ISE won't hit breakpoint if the script being debugged resides in a folder with [ or ] in the name.

Kev
  • 118,037
  • 53
  • 300
  • 385
  • Mine had issues with a folder name, too, but didn't involve brackets. If I removed the first character from a folder name (it was a "T"), it magically worked. I try and try, but can't figure out what exactly sets it off. Gosh. Edit: reboot didn't help, but second reboot did, with original folder name. – Vimes Mar 27 '17 at 20:24
1

Powershell apparently also has an issue with spaces in the folder names. It did not like 'My Documents' but did for 'Documents'. Once I switched my path in PowerShell within ISE the debugger worked again.

Dale Hurtt
  • 61
  • 3