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

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