Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

For exmaple on Linux there is a .bashrc or .cshrc file that are being sourced in in bash or shell to configure it on startup. What is the analogue file for Power Shell on Windows 7. And also what is the analogues command of source in Power Shell.

P.S. I want to give a configuration to power shell by that file and source it!

share|improve this question
    
Why downvote?? Did not understand the question?? Here is a link for downvoter ;) en.wikipedia.org/wiki/Configuration_file –  Narek Aug 27 '12 at 13:57

3 Answers 3

up vote 3 down vote accepted

Variables, aliases etc can be put into the Powershell profile. Some information/details can be found at http://technet.microsoft.com/en-us/library/ee692764.aspx

I do not know of a method of reloading/rereading the profile similar to source in Linux. From what I understand Powershell needs to be restarted to reread the profile.

share|improve this answer
    
Thanks, this is what I mean!!! –  Narek Aug 27 '12 at 13:56

In addition to p0rkjello answer, you can source a script similarly to ux by using dot: . $profile will source your profile script (if it exists). Of course you can use it to source any script, not only profile.

share|improve this answer
    
Thanks, this is the sourcing command I wanted!!! –  Narek Aug 27 '12 at 15:04

The profile is stored in the $PROFILE automatic variable. There are profiles for each host (console and Integrated Scripting Environment) for the current user or all users (four in all). The $profile automatic variable points to the current users's current host profile.

You can see the paths to each profile by running:

$profile | Select-Object *user* | Format-List

I prefer the $profile.CurrentUserAllHosts profile, that way I get all my helper functions in both the console and the ISE.

ise $profile.CurrentUserAllHosts

You can reload your profile by dot-sourcing the file:

. $profile

Good luck!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.