Powershell: Run a (init) script when powershell starts

Hi,

if have some own aliases or functions defined which should be loaded when powershell starts you can create a startup script.


Determine the best the script which fits your needs best

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PS D:\> Get-Member -InputObject $PROFILE -Type NoteProperty
   TypeName: System.String
 
Name                   MemberType
----                   ----------
AllUsersAllHosts       NoteProperty
AllUsersCurrentHost    NoteProperty
CurrentUserAllHosts    NoteProperty
CurrentUserCurrentHost NoteProperty
 
PS D:\ Get-Member -InputObject $PROFILE -Type NoteProperty | %{$PROFILE.($_.Name)}
C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
C:\Users\michael\Documents\WindowsPowerShell\profile.ps1
C:\Users\michael\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Crete one of those script files and places your code into it.

Michael

Leave a Reply