If you work with Powershell, you most likely end up doing things multiple times and even eventually have the Console look the way YOU want and load modules and Ps-snapins as you need to. The best way to do that using Powershell profiles.

Profiles, especially starting out, can be a little bit confusing though, as there are actually 6 profiles.

[table id=3 /]

The most common one to use is most likely the “Current User, Current Host – ISE” or the “Current User, Current Host – console” profile.

The ‘$profile’ variable points, depending if using the ISE or the console to the corresponding powershell script that has the profile information in it.

# From Console
[1:52:36 PM] C:\> $profile
C:\Users\awittig\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# From ISE
PS C:\> $profile
C:\Users\awittig\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

You can also get the hidden properties by using the -Force command:

[1:53:31 PM] C:\> $PROFILE | fl * -Force


AllUsersAllHosts       : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost    : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    : C:\Users\awittig\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\awittig\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Length                 : 75

To note, by default on a brand new computer there is no $profile there, so you have to create it on your own!

You can test if you have a powershell profile-file setup by running this command:

Test-Path $profile

The output should be a Boolean, either $true or $false. See below:

profile

As you can see, I do not have a profile file for the ‘CurrentUserAllHosts’ parameter.

To create a new $profile.CurrentUserAllHosts profile we can do this:

new-item $PROFILE.CurrentUserAllHosts -ItemType file -Force

There are several ways to edit the file that you just created:

  1. You can just navigate to the $profile.CurrentUserAllHosts file and right click on it
  2. You can open it for editing in the ISE: <pre class="lang:ps decode:true">ise $profile.CurrentUserAllHosts

</pre>

  1. You can open it with notepad / explorer <pre class="lang:ps decode:true ">explorer $profile.CurrentUserAllHosts</pre>
4. My favorite way, you can edit it with VIM

<pre class="lang:default decode:true ">vim $profile.CurrentUserAllHosts</pre>

(See my previous blog-post how to use vim for inline editing)</li> </ol> 

&nbsp;