4

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!

1
3

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.

0
3

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.

0
0

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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