Making PowerShell Profile Configuration Modifications

 

By default when you install PowerShell the PSConfiguration directory is created however the user Profile is not. The profile file is where you can configure your environment for the way the PowerShell command windows looks and acts. If you have no user profile created the default profile for PowerShell will be used.

 

To configure a new user Profile with a customized Prompt and color scheme follow the steps below:

 

  • Navigate to the following location:

 

C:\Documents and Settings\All Users\Documents\PSConfiguration

 

  • Create a file called: Profile.Ps1

 

Note: The .Ps1 file extension makes it executable.

 

  • Enter the following into the new Profile.Ps1 file and save it:

 

Function Prompt

{

Set-Location C:\

Write-Host ("MSH " + $(Get-Location) + "") -NoNewLine -ForeGroundColor Green

Return " "

}

 

Note: -NoNewLine causes the cursor to stay on the current line and not any subsequent lines.

 

If you receive an error message you must change your Execution Policy from the command window by entering the following:

 

Set-ExecutionPolicy RemoteSigned

 

Now the next time you open the PowerShell prompt your shell will have a new prompt the color that you have selected as the ForeGroundColor above.

 

 

Note: You can also use the MS-DOS command window trick by editing the properties for the PowerShell command window as well. Here you can set the colors for the Screen text, Screen background, Popup text and Popup background as well as change the Font and layout as well.

 

Configuring the Command Prompt Window

http://commandwindows.com/configure.htm

 

Published Friday, September 08, 2006 7:33 PM by dhite
Filed under:

Comments

# re: Making PowerShell Profile Configuration Modifications

Posted On Behalf of Lee Holmes

- The first part is that your post suggests that users always use the “All Users” profile.  That’s like a global startup file, so each person is better off using the one in their “My Documents” folder.  

For a description of how the different profiles work, you can see:

http://www.leeholmes.com/blog

TheStoryBehindTheNamingAndLocationOfPowerShellProfiles.aspx

or

http://www.leeholmes.com/blog

GettingStartedCustomizeYourPrompt.aspx

- Your suggested prompt function prevents users from changing to any directory other than C:\

As for the prompt function, you only have to remove the Set-Location call, and then users will be able to navigate around their system.

http://www.leeholmes.com/blog

Tuesday, September 12, 2006 6:32 PM by dhite