简体   繁体   中英

Powershell ISE loading old version of script

I have a script in Powershell ISE that I've added to my ISE profile (The only profile I have) through dot-sourcing. Whenever I open ISE, the version of the script that's loaded is 3.7.2 . However, the current version of the script (which the path for the dot-sourcing points to) is 5.3 . If I copy the dot source line in my profile and paste it and run it in ISE, the script will then correctly show as 5.3 . I've even removed the line from my profile, and the command still shows up when ISE is loaded.

Now, it seems like the script is being cached somewhere. I've checked in my WindowsPowerShell\\Modules folder, but I only have modules for ImportExcel and WASP . I never made it into a module in the first place, and I don't see it listed anywhere in Get-Module . Currently the line referencing adding my script is removed from my profile, and checking $profile.Contains("Create-Cert") returns False , which to me means that it's loading the correct file. Another thing I tried was to Dot-Source my $profile in ISE, which did seem to run successfully, but still didn't have the current version, whether or not the dot-sourcing inside $profile was there.

Is there somewhere else that Powershell could be storing this old version of this script? I've searched my computer for references to it, but I can't even find an old version that matches 3.7.2 .

Edit: Another troubleshooting step that I've just attempted was to rename my profile and then open ISE. When I did this, the command no longer showed in my command list, and Get-Help Create-Cert came back with an error since it couldn't find it. I then changed the name of my profile back to Microsoft.PowerShellISE_profile.ps1 , closed and opened ISE again, and the command loaded with version 3.7.2 again. It's almost like the command is embedded into the profile itself, which I don't even think should be possible.

One additional thing I want to note is that this script exists on a server, and not locally on the computer. I don't think that should matter, since the server is accessable the entire time, but perhaps there's something caching due to that fact.

Edit 2: On recommendation of Tom Collins, I created a new profile and added just the line concerning my script to it, and this time it worked. When ISE loaded, it correctly loaded version 5.3 . I then swapped the naming of my old and new profile, and suddenly it loaded the correct version again. I've tested closing and opening it a few times, and now it's loading 5.3 each time. I'm still at a complete loss for what actually fixed it, and if anyone is willing to offer a deeper explanation I'd be willing to know more.

Adding my triage in as an answer.

Next step I'd take is to rename the original profile, load ISE to confirm it isn't loading, and then manually rebuild a new ISE profile file with just the script (and minimal pre-reqs). Save that as the new profile file and re-run. If that works, then there's something in your original profile that is loading the old script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM