A little tip for those that are debugging and executing scripts. If you are calling Import-Module always use -Force on the end so it will force the script to reload during your session.
Import-Module c:\myscript.ps1m -Force
This will save you a lot of headaches during debugging and troubleshooting. For performance reasons, if you wanted to do this only when in the ISE you could wrap it in an if and use a function like this to check if you are in the ISE:
function Test-IsISE {
# try...catch accounts for:
# Set-StrictMode -Version latest
try {
return $psISE -ne $null;
}
catch {
return $false;
}
}
I found this snippet on stackoverflow
No comments:
Post a Comment