Image: Dekdoyjaidee, Getty Images/iStockPhotos

PowerShell (PS) can mean many things depending on the role of the user. For causal users, it’s nothing more than a means to execute scripts that allow for certain tasks to occur. Intermediate users may find that it can be used to obtain actionable information or analyze chunks of data. For more advanced users, PS represents how they do everything on client devices, especially Windows-based nodes.

SEE: Top 5 programming languages for systems admins to learn (free PDF) (TechRepublic)

The use of profiles, while not a requirement to use PowerShell, can help those who wear several hats within their IT organizations or simply prefer to keep an organized set of tools at the ready whenever working from PS. The profiles are flexible enough to include modules, functions, variables—essentially, anything one might commonly use or reference—can be added to the profile(s) making the console ready to use at launch.

Microsoft has even included various versions of profiles that allow for customizing the environment for different groups. For example, the version of the profile that references all users, all hosts can be used by admins to pre-configure PS so that certain functions that the organization has deemed should be included on all devices can be shared among all users of that device. This allows for flexibility when used in conjunction with other profiles to ensure that the shell will always be ready for anyone, regardless of what device they are using.

SEE: PowerShell 7.0: Eight changes you need to know (TechRepublic)

Default profiles and their locations

By default, PS uses profiles that are mapped to the $Profile variable. However, depending on what value you wish to edit, you can match the following variables to their locations and descriptions to best decide which profile will suit your needs and that of your organization and its users.

$Profile or $Profile.CurrentUserCurrentHost

Current user, current host

$PSHomeProfile.ps1

$Profile.CurrentUserAllHosts

Current user, all hosts

$PSHomeMicrosoft.PowerShell_profile.ps1

$Profile.AllUsersCurrentHost

All users, current host

$HomeDocumentsPowerShellprofile.ps1

$Profile.AllUsersAllHosts

All users, all hosts

$HomeDocumentsPowerShellMicrosoft.PowerShell_profile.ps1

Creating new profiles

As mentioned in the default profiles section, PS uses a number of profiles that are saved to different locations that offer multiple possibilities for configuring the PowerShell environment and session. To avoid overwriting any existing profiles, entering the command below will first check for the existence of a default profile. If found, the command will exit. If not, the command will continue with the creation of a new default profile.

if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }

Editing existing profiles

Before you can gain the benefits of using your newly created profile, you’ve got to edit the file to add your customizations. Doing so is as simple as editing a text file, using your favorite text-based editor or the Integrated Scripting Environment (ISE) that is included alongside PowerShell (in Windows environments). You can manually open the PS1 file created that holds your profile settings, or you can run the command below that will do it for you, using the native Notepad app found in Windows installations.

Notepad $Profile

Once the file is opened in the editor, add your functions, variables, alias, modules—basically anything and everything you might wish to include—that will customize your session(s) to your needs. Repeat the process for each profile you wish to edit, saving each file when you’re done.

Working without profiles

It is possible to launch PowerShell in its default state, without any pre-configured profiles. Whether you need to troubleshoot your current profile or merely wish to run PS without any additional configurations, open a new CMD.exe shell (or right from the PowerShell.exe prompt), and enter the following command:

powershell.exe -NoProfile

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays