PowerShell profile does not load

I created the file C:\Users\<myname>\Documents\WindowsPowerShell\profile.ps1; however, PowerShell does not load it on launch. I have tested both the default PowerShell as well as VS Code's integrated PowerShell. I also tried renaming the profile.ps1 file to Microsoft.PowerShell_profile.ps1, but this changed nothing. I relaunched the applications in question after each change.

Running Test-Path $profile.CurrentUserAllHosts returns True.

The profile currently only contains one line (Set-PSReadlineKeyHandler -Key Tab -Function Complete). After launching PowerShell or VS Code's integrated shell, running Get-PSReadlineKeyHandler | findstr -i Tab reveals that it has not been set. Copying and pasting the line from the profile, running it, then running the Get-... command again reveals that it is properly set, and the change does what it's supposed to. Relaunching the shell reverts back to the default.

Is there some other step I need to do to get PowerShell to execute the profile? (I come from a Linux/UNIX background and I assume PowerShell works similarly, but of course PowerShell is designed completely differently). If there is no extra step, why does PowerShell not load the profile in this case?

Additional Info:

> $profile | Format-List * -force
AllUsersAllHosts       : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost    : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    : C:\Users\<myname>\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\<myname>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Length                 : 76

Solution: change execution policy

  1. Launch PowerShell as administrator
  2. Set-ExecutionPolicy -ExecutionPolicy Unrestricted

The error message as shown:

. : File C:\Users\<myname>\Documents\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ . 'C:\Users\<myname>\Documents\WindowsPowerShell\profile.ps1'
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

The Lesson:

The odd thing is that I saw an error message (which was not important) every time I launched PS before so I just got used to ignoring it. Creating the profile.ps1 file caused the execution policy error to appear, but also caused the previous error to stop appearing, so I just skipped over it because, without reading the details, it just looked like the same block of red text. (The previous error now appears to be impossible to replicate, for some reason.)

In the end, the problem can be described as "User got used to ignoring trivial and unimportant error, so the important error went unnoticed."