Profile file is a powershell script that will run while the powershell console is starting. This way we can have our environment prepared for us each time we start new powershell session.
Typical things we want to do on powershell start are:
There are several profile files and locations that have different uses and also hierarchy of start-up order:
Host | User | Path | Start order | Variable |
---|---|---|---|---|
All | All | %WINDIR%\System32\WindowsPowerShell\v1.0\profile.ps1 | 1 | $profile.AllUsersAllHosts |
All | Current | %USERPROFILE%\Documents\WindowsPowerShell\profile.ps1 | 3 | $profile.CurrentUserAllHosts |
Console | All | %WINDIR%\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 | 2 | $profile.AllUsersCurrentHost |
Console | Current | %USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 | 4 | $profile.CurrentUserCurrentHost |
ISE | All | %WINDIR%\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1 | 2 | $profile.AllUsersCurrentHost |
ISE | Current | %USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1 | 4 | $profile.CurrentUserCurrentHost |