powershell profile location

Welcome Forums General PowerShell Q&A powershell profile location

This topic contains 2 replies, has 2 voices, and was last updated by

2 years, 8 months ago.

  • Author
  • #38402

    Points: 0
    Rank: Member

    I am trying to use my old scripts on a new computer and I need to know what folder the powershell profile needs to be placed in. I tried using microsofttechnet, but the answer I got didn't work. This is my profile:

    $a = (Get-Host).UI.RawUI
    $a.BackgroundColor = "black"
    $a.ForegroundColor = "white"
    $env:path += ";C:\My Documents\PowerShell BACKUP\scripts"

    I am using windows 10

  • #38416

    Points: 26
    Rank: Member

    Hi Ryan, the locations of the profiles can be the following (replace by your own username):


    You will ask yourself, why so many files? Look at this code (executed in a PowerShell console):

    PS C:\> $PROFILE | Select-Object -Property AllUsersAllHosts,AllUsersCurrentHost,CurrentUserAllHosts,CurrentUserCurrentHost | Format-List
    AllUsersAllHosts       : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
    AllUsersCurrentHost    : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
    CurrentUserAllHosts    : C:\Users\\Documents\WindowsPowerShell\profile.ps1
    CurrentUserCurrentHost : C:\Users\\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

    So, here you can see that there are several profile scripts. These don't exist by default, you need to create it.
    If you are the only one using that profile code, and want to use the profile in all the PowerShell shells you are starting,
    create this file and put your code into it: C:\Users\\Documents\WindowsPowerShell\profile.ps1

    If you want to have the profile available in all the PowerShell ISE's that you will start,
    create this file and put your code in: C:\Users\\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

    The profile files in the system32 directory are ment for All Users, not only you.

    Here's a good reference: https://technet.microsoft.com/en-us/library/bb613488(v=vs.85).aspx

    Also make sure that your execution policy is set to RemoteSigned:

    Set-ExecutionPolicy RemoteSigned

    And another tip, Sapien has a specific tool for editing profile files: https://www.sapien.com/software/productivity_pack#PowerShell Profile Editor 2015

  • #38417

    Points: 0
    Rank: Member


The topic ‘powershell profile location’ is closed to new replies.