I recently installed Windows 10, which includes V5 of PowerShell, or 5.1.14393.206
to be exact ($PSVersionTable.PSVersion
).
On new computers I install PSReadline. However, Windows 10 comes with it already installed.
My question is, how is PSReadline loading automatically, when there is no profile to import it, (or call a command from it)?
As proof, I ran this code:
$PROFILE | Get-Member -MemberType NoteProperty | % {
$path = $PROFILE.$($_.Name);
$exists = Test-Path $path;
[pscustomobject]@{ Path = $path; Exists = $exists }
}
To get this:
Path Exists
---- ------
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 False
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 False
C:\Users\tahir\Documents\WindowsPowerShell\profile.ps1 False
C:\Users\tahir\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 False
I have gone through all of https://stackoverflow.com/a/23942543/288393:
Import-Module
for PSReadline is made because there are no profiles to call it.Can someone explain this behavior?
There is special code in the console host to load PSReadline if the process is interactive. You can see the code here.