PowerShell: Automatically load scripts or functions when starting PowerShell

Scenario: You want to kick off certain scripts or functions when opening PowerShell

Solution:
1. Navigate to: C:\Users\<you>\Documents\WindowsPowerShell\

2. Create a .ps1 script in this directory called: profile.ps1

3. Inside the profile.ps1, add the following command(s) to call and run in your .ps1 scripts. Obviously, change the script name. I have multiple scripts that contain Authenticate.ps1 at the end of the filename which auto-authenticates me to specific services:

Get-ChildItem C:\Scripts\Powershell\*Authenticate.ps1 | %{. $_ }


Boom.

Leave a comment