Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
Windows Powershell Profiles


Bookmark and Share

By: Ying Li
Posted On: 7/13/2007

Understanding the Profiles

This article was Previously posted on Ying Li's Blog

As in you can see in my previous post, when you add aliases, functions, and variables to Windows PowerShell, you are actually adding them only to the current Windows PowerShell session. If you exit the session or close Windows PowerShell, the changes are lost.

To retain these changes, you can create a Windows PowerShell profile and add the aliases, functions, and variables to the profiles. The profile is loaded every time that Windows PowerShell starts.

You can have four different profiles in Windows PowerShell. The profiles are listed in load order. The most specific profiles have precedence over less specific profiles where they apply.

%windir%\system32\WindowsPowerShell\v1.0\profile.ps1

This profile applies to all users and all shells.

%windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1

This profile applies to all users, but only to the Microsoft.PowerShell shell.

%UserProfile%\My Documents\WindowsPowerShell\profile.ps1

This profile applies only to the current user, but affects all shells.

%UserProfile%\\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

This profile applies only to the current user and the Microsoft.PowerShell shell.

Creating a Profile

Windows PowerShell profiles are not created automatically. To create a profile, create a text file with the specified name in the specified location. Typically, you will use the user-specific, shell-specific profile, known as the Windows PowerShell user profile. The location of this profile is stored in the $profile variable.

To display the path to the Windows PowerShell profile, type:

$profile
To determine whether a Windows PowerShell profile has been created on the system, type:

test-path $profile
If the profile exists, the response is True; otherwise, it is False.

To create a Windows PowerShell profile file, type:

new-item -path $profile -itemtype file -force
To open the profile in Notepad, type:

notepad $profile
To create one of the other profiles, such as the profile that applies to all users and all shells, type:

new-item -path C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 -itemtype file -force

  myITforum.com ©2010 | Legal | Privacy