header image

PowerShell v6: #4 profiles

Posted by: | November 23, 2017 Comments Off on PowerShell v6: #4 profiles |

Windows PowerShell (v1-v5.1) has always used profiles to configure your PowerShell session.  You need execution policy set to something other than restricted so that the profile script can run.

 

You can have up to 4 profiles:

Description                Path 
-----------                ---- 
Current User, Current Host $Home\[My ]Documents\WindowsPowerShell\Profile.ps1 
Current User, All Hosts    $Home\[My ]Documents\Profile.ps1 
All Users, Current Host    $PsHome\Microsoft.PowerShell_profile.ps1 
All Users, All Hosts       $PsHome\Profile.ps1

 

Most people only use 1. I use $Home\[My ]Documents\Profile.ps1 as my profile as its easier to change then in $PShome.

 

In PowerShell v6 your profile options are

Description                Path 
-----------                ---- 
Current User, Current Host $Home\Documents\PowerShell\Profile.ps1 
Current User, All Hosts    $Home\Documents\Profile.ps1 
All Users, Current Host    $PsHome\Microsoft.PowerShell_profile.ps1 
All Users, All Hosts       $PsHome\Profile.ps1

 

The location of $PShome changes in PowerShell v6.  In Windows PowerShell v1 through v5.1  its:

PS>  $pshome
C:\Windows\System32\WindowsPowerShell\v1.0

In PowerShell v6 its:

PS C:\scripts> $pshome
C:\Program Files\PowerShell\6.0.0-beta.9

 

Be careful of using $Home\Documents\Profile.ps1 as it will also be applied to Windows PowerShell. The safest place to put your PowerShell v6 profile is $Home\Documents\PowerShell\Profile.ps1 as it will still apply when you upgrade to the next version e.g. from a beta version to release candidate or full release.

under: PowerShell v6

Comments are closed.

Categories