Why won't PowerShell ISE let me set breakpoints when running as Administrator?
Asked Answered
H

6

16

Having failed to get PowerGUI to work properly I've fallen back on PowerShell ISE. However if I run this as Administrator it won't let me set any breakpoints.

If I launch as normal (my login is a member of Administrators) all is well but because I need to script some tasks that require full administrator rights this is no good.

I have saved the script as a proper file (i.e. it's not "untitled1.ps1") but no joy.

I'm running Windows 7 x64 Ultimate.

Strangely this doesn't seem to be a problem on my Windows 2008 R2 dev box (I'm logging in as user that is a member of Administrators then running PS ISE "As Administrator" and breakpoints are set and hit.

Any ideas why this would be?

Hungarian answered 6/12, 2010 at 16:28 Comment(0)
H
6

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.

Hungarian answered 7/12, 2010 at 0:28 Comment(3)
Now that figures. The whole '*.[ch]' syntax is something I rarely use yet squares braces in filenames have caused me my fair share of grief too.Ashanti
Also, if you haven't physically saved the file yet, then toggle breakpoint will be unavailableLifeline
I had a script in a One Drive folders and was not able to set breakpoints but I could run it. I open the same script into a folder not mapped to OneDrive and it worked. Then I switch back to the other script and also worked.Misrule
M
24

I also faced the same issue, saving the file to a physical location enabled all debugging capabilities.

Maximin answered 9/11, 2016 at 23:10 Comment(0)
H
6

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.

Hungarian answered 7/12, 2010 at 0:28 Comment(3)
Now that figures. The whole '*.[ch]' syntax is something I rarely use yet squares braces in filenames have caused me my fair share of grief too.Ashanti
Also, if you haven't physically saved the file yet, then toggle breakpoint will be unavailableLifeline
I had a script in a One Drive folders and was not able to set breakpoints but I could run it. I open the same script into a folder not mapped to OneDrive and it worked. Then I switch back to the other script and also worked.Misrule
N
1

I faced the same problem even when the powershell ISE was running as administrator, saving the script to physical directory allowed me to have debug capabilities.

Navicert answered 13/11, 2023 at 9:31 Comment(0)
A
0

I notice you're running x64. Is there any chance that you're running x64 ISE but have only set the execution policy away from restricted on x86 (or vice-versa).

Ashanti answered 6/12, 2010 at 18:17 Comment(1)
see my answer. PowerShell has square bracket issues.Hungarian
B
0

I am using Visual Studio Code and in my case, I was missing the powershell extension.

Bookbindery answered 24/10, 2022 at 12:25 Comment(0)
D
0

Was facing the same issue because I had used other editor to make changes to the ps1 file. After opening the file with PowerShell ISE and clicking "Save" solved the issue for me.

Disposition answered 19/12, 2022 at 8:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.