This seems based on the assumption that PowerShell Studio uses a 'different' PowerShell. It does not.
Your code is simply passed to the PowerShell engine for execution.
The ISE is generally the worst place to look for verification of anything, as you can never be sure when the variable was actually set to something. Runspace contamination can play tricks on you.
You should always start a new console process to verify things like this. As a different host and maybe a different threading model can make a difference,
I always suggest to test with or without STA mode. Assuming that the pasted code is part of something larger, you can always export the script and run that in a console to test.
You can also run that directly in a console from within PowerShell Studio. From your input I cannot tell if you tried that or not.
Also, just to be sure, there is nothing in PowerShell Studio that would make code skip ahead under any condition.
As you did not include the output, I unfortunately cannot comment on that.
I am moving this post to the general PowerShell area. Maybe someone else has additional input.
Your code is simply passed to the PowerShell engine for execution.
The ISE is generally the worst place to look for verification of anything, as you can never be sure when the variable was actually set to something. Runspace contamination can play tricks on you.
You should always start a new console process to verify things like this. As a different host and maybe a different threading model can make a difference,
I always suggest to test with or without STA mode. Assuming that the pasted code is part of something larger, you can always export the script and run that in a console to test.
You can also run that directly in a console from within PowerShell Studio. From your input I cannot tell if you tried that or not.
Also, just to be sure, there is nothing in PowerShell Studio that would make code skip ahead under any condition.
As you did not include the output, I unfortunately cannot comment on that.
I am moving this post to the general PowerShell area. Maybe someone else has additional input.
Statistics: Posted by Alexander Riedel — Wed May 29, 2024 4:49 pm