Thursday, December 21, 2006

Configuring PowerShell

Enable scripts - in order to execute script in PowerShell, the default Executionpolicy of "Restricted", has to be changed to "Unrestricted":

Set-Executionpolicy Unrestricted

Instead of "Unrestricted" you could also selec RemoteSigned, AllSigned, Restricted, Default (to reset to the PowerShell default)

Configure my profile
Determine where my profile is stored through the following default variable:


Edit it by using

notepad $profile

To create the file first:

new-item -path $profile -itemtype file -force

# Set Aliases
set-alias n notepad

# Set Prompt
function prompt
$nbsp;$nbsp;$nbsp;$nbsp;Write-Host ("--< " + $(Get-Location) + " >--< " + $(Get-Date) + " >--") -foregroundcolor DarkRed
$nbsp;$nbsp;$nbsp;$nbsp;Write-Host "PS>" -nonewline -foregroundcolor Cyan
$nbsp;$nbsp;$nbsp;$nbsp;return " "

  • %UserProfile%\My Documents\WindowsPowerShell\profile.ps1 - This profile applies only to the 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.
  • %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.
Read more about it all here.

1 comment:

Joe8908 said...

Thanks Jakob. That was just what I was looking for. JK.