IT tutorials
 
Windows
 

Windows Server 2008 : Creating and Running a PowerShell Script - Creating a PowerShell Profile

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/29/2013 7:58:25 PM

The PowerShell profile is a PowerShell script file (named profile.ps1 or Microsoft.PowerShell_profile.ps1) that creates the PowerShell environment every time Windows PowerShell is started. It can include aliases, PowerShell functions, or any other type of PowerShell modifications you want.

Tip

The default location of the user’s PowerShell profile is C:\Users\username\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1. However, it doesn’t exist by default.


You can view the location and name of the profile using the $profile variable executed at the PowerShell prompt as follows:

PS C:\> $profile
C:\Users\Darril\Documents\WindowsPowerShell\
Microsoft.PowerShellISE_profile.ps1

It’s important to realize that even though the $profile points to this file and this location, it doesn’t mean the file actually exists. The steps in the following table show how to test for and create a profile used for the current user.

Note

You can also modify the profile with Notepad or the Windows PowerShell Integrated Scripting Environment . These steps use Notepad.


PowerShell CommandComments
PS C:\> $profile
C:\Users\Darril\Documents\
WindowsPowerShell\Microsoft.
PowerShellISE_profile.ps1

Displays the path and name of the profile.
PS C:\> test-path $profile

The test-path cmdlet identifies if the path exists. Returns true if it exists and false if not.
PS C:\> new-item -path $profile
-type file -force

The new-item cmdlet creates the path and the profile file identified in the $profile variable. If test-path $profile returned false before, it will return true now.

Note

The -force switch overwrites the profile file, if one exists.

PS C:\> notepad $profile

Opens the profile file with Notepad. If it was just created, it will be blank. At this point, you can modify the profile as desired.

Both local and global PowerShell profiles can exist. The following table compares these two profiles.

Global and Local ProfilesComments
Global profile
C:\windows\system32\
WindowsPowerShell\v1.0\profile.ps1

Open with:
PS C:\> notepad c:\windows\system32\
WindowsPowerShell\v1.0\profile.ps1

If a global profile exists, it is used for all users.

Note

Even though the path includes “v1.0,” this profile does apply to Windows PowerShell v2, which is installed on Windows 2008 R2.

Local profile
c:\users\username\documents\
windowspowershell\
microsoft.powershell_profile.ps1

Open with:
PS C:\> notepad $profile

Applies to currently logged-on user and takes precedence over global profile. The $profile variable holds the path for the local profile.

Tip

If PowerShell profiles exist in both locations, the local profile takes precedence over the global profile if there are any conflicts. For example, if the global profile sets the location to c:\data, but the local profile sets the location to c:\scripts, the location would be set to c:\scripts.
 
Others
 
- Windows Server 2008 : Creating and Running a PowerShell Script - Setting the Security Context
- Windows 8 : Cloud Connections - Office 2013
- Windows 8 : Cloud Connections - SkyDrive (part 3) - To access SkyDrive from a browser
- Windows 8 : Cloud Connections - SkyDrive (part 2) - To open SkyDrive inside Windows Explorer
- Windows 8 : Cloud Connections - SkyDrive (part 1) - To add a file to the tile-based SkyDrive app
- Windows 8 : Cloud Connections - Windows Essentials (part 2) - To install Windows Essentials
- Windows 8 : Cloud Connections - Windows Essentials (part 1)
- Windows 8 : Cloud Connections - Windows Live
- Windows 8 : Cloud Connections - Microsoft Account (part 2) - To enable a roaming profile
- Windows 8 : Cloud Connections - Microsoft Account (part 1) - To convert a local account to a Microsoft account
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us