Moving function across modules; now unable to auto-load the module

I moved a function (we’ll call it Get-MyFunction) from Module1 to Module2 (which I’ve never done before). If I run Get-Command Get-MyFunction, it fails to find the function, but it auto-loads Module1 (which was not already loaded). If I run Import-Module Module2, then run Get-Command Get-MyFunction, it is successful and finds it in Module2.

Everything with the function works as expected if I manually import the Module2 first, but some cache somewhere seems to think that it is still stored in Module1. I’ve confirmed there are no references in Module1’s module file or manifest file (including exported commands). What am I missing?

This is occurring on Windows Server 2019 (PSVersion 5.1.17763.503). I cannot recreate the problem on my Windows 10 1809 computer (PSVersion 5.1.17763.592).


Did you try opening a new PowerShell console the Get-Command ?
You would have already tried this, but still…

Yes, I’ve done everything except restart the server.

can you please check server PowerShell profile if it have some reference store over there?

How to check?
psedit $profile

Yes, I should have mentioned that. I have no profile on the server (confirmed). Thanks.