• ARTICLES
SEARCH

How-To Geek

How to Create a PowerShell Profile

PowerShell is a great way to automate almost anything in Windows. However, its not just a scripting language. If you find yourself using it as a command line shell it may be useful to store your functions and customizations in a profile that gets loaded every time you load the Console. Read on to find out how.

Creating a PowerShell Profile

The first thing we need to do is check if you already have a profile. There is an automatic variable, $Profile, that stores the fully qualified location of the PowerShell profile. An easy way to check if your profile exists is to use the Test-Path cmdlet on the $Profile variable.

Test-Path $Profile

image

As you can see we don’t have a profile file yet, so we will need to create one, you can easily do that with the New-Item cmdlet.

New-Item –Path $Profile –Type File –Force

Note: Using the force parameter will cause a profile to be created even if you already had one. This means your old profile will be overwritten.

image

You can edit your profile using notepad, which is easily started using PowerShell.

notepad $Profile

image

You can put any commands,functions,alias’s and even module imports into your PowerShell profile. Here are some things examples and ideas of what you can put in your profile.

Since PowerShell 3 comes with updatable help, the easiest way to keep your help files updated is by adding the Update-Help cmdlet to your profile.

Note: Update-Help will only download help files once a day, this is fine for us since we don’t want it updating help files every single time we open the console. If you do want it to update every time you can use the force parameter.

image

Another thing I like to add to my profile is custom functions that I have written over time, this makes them automatically available in the console. Below you can see that you can literally just copy a function out of a script and put it in your profile. It will then be available for use in the console.

image

Finally, I also have some customizations to the console. One of my favorite ones is shown below, it basically determines if you have opened an elevated PowerShell console and changes the font color, this way I always remember that I am running with elevated privileges.

image

What do you have in your profile? Let us know in the comments.

Taylor Gibb is a Microsoft MVP and all round geek, he loves everything from Windows 8 to Windows Server 2012 and even C# and PowerShell. You can also follow him on Google+

  • Published 11/10/12

Comments (9)

  1. Terry

    The text for Get-LatestArticles is truncated.

  2. mmg1818

    for what is PowerShell ?

  3. Rodger

    MORE!

  4. Saeed Iranzad

    It’s like a programming language. Where can I find its commands and characters? or is there any tutorial for Powershell?

  5. ViditM14

    Nice! Will try it soon..
    P.S. Will it work on Windows 7? ‘coz the pics in this post are probably of Windows 8.

  6. JohnM

    Powershell is a scripting language and is installed on Windows 7 and onwards by default
    for Windows XP you need to download it here http://support.microsoft.com/kb/968929

  7. Zo

    Been doing some work with BITS lately so I added

    import-module bitstransfer

  8. Abhinav

    What does it automate?
    Browser ??

  9. chen

    the Get-LatestArticles text isn’t complete

    can you type the full code for us noobs ?

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!