Some custom Powershell scripts and settings I like to have available for all Powershell sessions. To do this I add the following to my Powershell profile so it loads all scripts in a directory when opening. First create a directory to store the script files. I use c:\users\<USER>\ProfileScripts now add your scripts to that directory. For some starting scripts you can download a few of mine here PSProfile on Github
To edit the Powershell profile open a Powershell prompt and type:
notepad $profile
Code language: PHP (php)
Enter the following and update USER to be your username
#load scripts
$psdir = "C:\Users\<USER>\ProfileScripts"
Set-Location $psdir
#autoload script directory
$cnt = (Get-ChildItem $psdir).Count
For($i = 0; $i -le $cnt; $i++)
{
Write-Progress -Activity "Loading Scripts" -status "Loading $i" -percentComplete ($i / $cnt*100)
}
Get-ChildItem "${psdir}\*.ps1" | %{.$_}
Set-Location c:\users\<USER>
Write-Host -foregroundcolor green "Custom Powershell Environment Loaded"
Code language: PHP (php)
Now save and open a new powershell prompt and all ps1 files in the ProfileScripts directory will be loaded.
Read full article here