Create a Powershell profile

Scripting

A Powershell profile launches when you start Powershell. Bascially a profile is a function runs each time you open a Powershell session. As there are different ways to open Powershell (console, Powershell ISE, 3rd party app) , there are different profiles you can create. The profile is a feature of the host applications and not of the Powershell engine. The different profiles are stored in different locations so can contain different code. There is also a different order in which they are loaded. None of these script files exist by default, and not all the directory paths exist by default. Profile scripts are loaded in the order shown here, and are loaded only if the directory path and file exists when the shell session is started.

Profile Script PurposeConsole host applicationISE host application
Current user, current host$home\Documents\WindowsPowerShell \Microsoft.PowerShell_profile.ps1$home\Documents\WindowsPowerShell \Microsoft.PowerShellISE_profile.ps1
Current user, all hosts$home\Documents\WindowsPowerShell \Profile.ps1$home\Documents\WindowsPowerShell \Profile.ps1
All users, current host$pshome\Microsoft.PowerShell_profile.ps1$pshome\Microsoft.PowerShellISE_profile.ps1
All users, all hosts$pshome\Profile.ps1$pshome\Profile.ps1

Creating a (current) user Profile

Launch powershell.

Check if you already have a Powershell profile enter:

If it returns ‘True’ then you have a powershell profile if ‘false’ then we can create a by typing:

We can now edit the profile. Either navgiate to “C:\Users\<username>\Documents\WindowsPowershell\Microsoft.Powershell_profile.ps1

or we can launch notepad from Powershell and edit:

 

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scripting
Install Vmware PowerCLI

PowerCLI is really easy to install now. From an Administrative Powershell window just enter: Install-Module -Name VMware.PowerCLI Minimum Powershell Version must be v3.   Offline Install of PowerCLI Accessing the PowerCLI Modules We’re now ready to download the PowerCLI modules. This task will require a system with internet access. This …

Scripting
Pass credentials with Powershell – 3 Ways

Interactive Here’s your typical scenario.   You have a script that requires credentials internally.  So to provide those credentials you would do something like $MyCredentials=GET-CREDENTIAL –credential “CONTOSO\Username” and you of course see a box like this normally on the screen Then you would type in the password and life would go …

Deployment
MDT – Joining a Computer to a Domain Using PowerShell

Using PowerShell scripts within a task sequence provides more flexibility than using the CustomSettings.ini file to join a computer to a domain. The parameters of the CustomSettings.ini file are common to any deployment you perform. That’s why creating a custom PowerShell script to join your domain will be customize to …