I have been working in a script using Powershell ISE for a few months and for some reason, a weird issue started to happen today.
If I edit the script, then save and run it from the same ISE window/session, it seems the changes made has no affect. If I run the code again after close and reopen the ISE, then I see the effect of the changes.
That issue happens for every single change. I have rebooted the system and the issue still. How could it be?
Check if you have the functions defined in the correct order in your file.
Powershell processes in order (top-down) so the function definition needs to be before the function call:
function email($text){
#email $text
}
#Do things
foreach{
email($_)
}
The ISE keeps the functions from the last run in memory, so if you have the function call above the function definition, it will run the version from the previous run.
I had the same problem and stumled upon the solution while searching another topic: Powershell script not recognizing my function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With