PowerShell can't "dot source" profile following system cleaning

975 views Asked by At

I have a problem where PowerShell will no longer run my Microsoft.Powershell_profile.ps1/Profile.ps1 script stating it can't "dot source" the file. This started after I ran a registry cleaner and system optimizer on my machine. Now, I can't figure out what setting has changed, been added, or revoked.

Things to note:

  • The console always defaults to 'ConstrainedLanguage' because of the attempt to "dot source"
  • I have tried setting the -ExecutionPolicy to both "Unrestricted" and "RemoteSigned" to no effect
  • Issue exists in both version 5 & 6
  • If I run the "PowerShell Integrated Console" in VS Code, as opposed to in the terminal window, it runs fine showing "FullLanguage"
  • The contents of the profile file do not matter - if I use an empty file, it still won't run.
  • Placing "Microsoft.Powershell_profile.ps1" in the "\documents" folder does NOT produce a "dot source" error, however it also doesn't recognize any commands from within the profile script.

Things I have tried:

  • Setting to "FullLanguage" via $ExecutionContext.SessionState.LanguageMode = 0 results in "Cannot set property. Property setting is supported only on core types in this language mode."
  • Setting the "__PSLockdownPolicy" property to 0 in the registry at "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\" does nothing for v5 and crashes v6
  • Moving the profile file between $home, "\documents", and $pshome (location dependent on version) to no effect (with the above exception)
  • Adjusting name between "Microsoft.Powershell_profile.ps1" and "Profile.ps1" (normally adjusted to match intended audience ("All Users", for example) but am trying variations in hopes of making work)
  • Uninstalling and re-installing different 5.x and 6.x versions to no effect
  • Running "Powershell -noprofile" doesn't load the profile, so no error but still runs in "ConstrainedLanguage"
  • Verified AppLocker is not running / has not rules in place
  • Verified Controlled Folder Access is off

Any help would be appreciated.

0

There are 0 answers