PowerShell Profiles and Prompts

To get the path of your PowerShell profile, you can use the built-in $Profile variable. If your profile exists, you can open the profile in notepad using the Invoke-Item cmdlet.

clip_image001

If the profile doesn't exist, as you create it using the New-Item cmdlet. To make sure you can create the file even if part of the path doesn't already exist using the -Force parameter.

Once the profile has been created, you can open it with the Invoke-Item cmdlet.

clip_image002

To customise the PowerShell prompt, you can create a prompt function like I have below.

clip_image003

clip_image004

You could include some Environmental variables in the prompt function to make the PowerShell prompt provide some very useful information, for example:

clip_image005

clip_image006

You can also customise the UI using your profile. This is done by modifying properties of the $Host built-in variable.

clip_image007

clip_image008

Popular posts from this blog

Get local computer UUID/GUID using Windows Powershell

gPLink and gPOptions

PSLoggedOn Getting Started on Windows Server 2008 R2