PowerShell Script to Create PowerShell Profile

    Utilizing a PowerShell profile can help any PowerShell user save time getting up and running with their work.  For those unfamiliar a PowerShell profile is a file you can store any PowerShell commands that you want to run when you fire up a PowerShell console (or ISE.)  In my typical profiles (example here) I load assemblies (like SharePoint 2007 DLL), set aliases, set environment variable values (such as max history), and perform other general customizations to make my work easier.  Below is a sample script that will check to see if a PowerShell profile (Console or ISE) exists and create it if not found.  The .ps1 script file version can also be downloaded from my SkyDrive here.

Note: if downloading the .ps1 file, be sure you have enabled unsigned scripts to run on your machine as I have not signed mine.


$folderExists = test-path -path $Env:UserProfileDocumentsWindowsPowerShell

if($folderExists -eq $false)


    new-item -type directory -path $Env:UserProfileDocumentsWindowsPowerShell > $null

    echo "Containing folder for profile created at: $Env:UserProfileDocumentsWindowsPowerShell"



$profileExists = test-path -path $profile

if($profileExists -eq $false)


    new-item -type file -path $profile > $null

    echo "Profile file created at: $profile"


    A few things to note while going through the above script.

  • $Env:UserProfile represents the personal user folder (c:documents and settings…. on older OSes like XP and c:Users… on Win 7) so it adapts to whichever OS you are running but was tested against Windows 7 and Windows Server 2008 R2.
  • “ > $null” sends the command to a null stream.  Essentially this is equivalent to DOS scripting of “@ECHO OFF” by suppressing echoing the command just run, but only for the specific command it is appended to.  I haven’t yet found a better way to accomplish command suppression, but this is definitely not required for the script to work.
  • $profile represent a standard variable to the file path of the profile file.  It is dynamic based on whether you are running PowerShell Console or ISE.



    In less than two weeks (Apr. 10th to be exact) I’ll be heading down to SharePoint Saturday Charlotte (SPSCLT) to give two presentations on using PowerShell with SharePoint.  Since I’ll be prepping a lot of material for PowerShell I thought it only appropriate to pass along this nice little script I recently created.  If you’ve never used a PowerShell profile this is a great chance to start using one.  If you’ve been using a profile before, perhaps you learned a trick or two to add to your toolbox.  For those of you in the Charlotte, NC area sign up for the SharePoint Saturday and see some great content and community with great folks.


      -Frog Out

5 thoughts on “PowerShell Script to Create PowerShell Profile

  1. Originally posted on: https://briantjackett.com/archive/2010/03/29/powershell-script-to-create-powershell-profile.aspx#530696Essay Writers, Sorry, I wasn’t getting notifications about comments on my blog for past month it appears so catching up. Glad you like my articles. I try to write about stuff that I run into and hopefully others can find something useful out of it. Lately I’ve been digging into more of the advanced PowerShell concepts and it’s really boosted my productivity. If you have any topics you’d like to hear more about feel free to drop me a line. Thanks. Brian


  2. Originally posted on: https://briantjackett.com/archive/2010/03/29/powershell-script-to-create-powershell-profile.aspx#564926Truly, regardless of who you are and what is your profession in life. When it comes to taking care of your children as well as your family, you will not care on what other people will say about it. Just like any other family men and women in this earth. By nature, man really care for his family and loved ones not only by giving their happiness and providing their needs. But, by assuring their good health condition and protecting them. This is the reason why vent filters and other air purifier products are created to provide your family 100% protection from breathing in polluted air.


Leave a Reply to Brian T. Jackett Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s