Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell: $profile is pointing to a path that I can't find and setting permanent path

I am looking at my $profile variable and I see that it is pointing to C:\users\username\Documents\windowsPowershell\Microsoft.Powershell_profile.ps1

However, when I attempt to browse to this directory I cannot find the folder/directory named WindowsPowerShell that is supposed to be in the documents folder. Any ideas?

I was hoping I could set a permanent path that is linked to my profile or at least loaded with it when Powershell is loaded. Am I on the right track here?

thanks!

-Dustin

like image 266
Dustin Hammond Avatar asked Jan 25 '12 02:01

Dustin Hammond


People also ask

How to find PowerShell PROFILE path?

The $PROFILE variable The $PROFILE automatic variable stores the paths to the PowerShell profiles that are available in the current session. To view a profile path, display the value of the $PROFILE variable. You can also use the $PROFILE variable in a command to represent a path.

What is NoProfile in PowerShell?

PowerShell.exe -NoProfile. When you launch PowerShell with NoProfile parameter, it ensures to run script in default PowerShell environment and run without any Windows PowerShell profile.


2 Answers

What you see for the path is right. It is the path for your user profile (for the console host) and it is normal to not see the folder and the file. You can create it and start using your profile - new-item -type file -path $profile -force

See here for more: http://technet.microsoft.com/en-us/library/dd315342.aspx

like image 133
manojlds Avatar answered Sep 22 '22 13:09

manojlds


This is the case when you mistakenly delete your profile file.

You can manually create the "Microsoft.Powershell_profile.ps1" at the location of your profile.

  1. execute $profile in cmd/powershell and you will get the location of your profile.
  2. Create the subsequent folders and the file.

In my case, it was "D:\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"

  1. So, I manually create the "WindowsPowerShell" folder inside Documents and the "Microsoft.PowerShell_profile.ps1" file in WindowsPowerShell.

  2. Then pasted the content in the profile.

    Import-Module posh-git

    Import-Module oh-my-posh

    Set-PoshPrompt -Theme Paradox

Hope this resolves your issue. :)

like image 40
7absec Avatar answered Sep 25 '22 13:09

7absec