This topic contains 2 replies, has 2 voices, and was last updated by
April 29, 2016 at 1:09 pm #38402ParticipantPoints: 0Rank: 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
April 29, 2016 at 3:50 pm #38416ParticipantPoints: 26Rank: Member
Hi Ryan, the locations of the profiles can be the following (replace by your own username):
C:\Windows\system32\WindowsPowerShell\v1.0\profile.ps1 C:\Windows\system32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 C:\Windows\system32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1 C:\Users\\Documents\WindowsPowerShell\profile.ps1 C:\Users\\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 C:\Users\\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
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:
And another tip, Sapien has a specific tool for editing profile files: https://www.sapien.com/software/productivity_pack#PowerShell Profile Editor 2015
April 29, 2016 at 4:16 pm #38417ParticipantPoints: 0Rank: Member
The topic ‘powershell profile location’ is closed to new replies.