Adding a Powershell Profile
The Powershell profile is equivalent to the ~/.bashrc file for bash in Linux. It helps load a desired configuration when a Powershell instance is run.
To test if there is a profile:
Test-Path $profile
The variable $profile
refers to the profile. If absent, this returns False
. If False
, create one:
New-Item -path $profile -type file -force
A typical (user) profile path looks like:
$home\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
where for me, $home = C:\Users\Ayon\
- Ayon is the username.
Once created, we can use an editor to edit the file. I use Sublime Text (cli: subl) for the purpose:
subl $profile
Script running permissions:
Running scripts on Powershell might be disabled by default. From this thread, we can use Powershell as Admin (Win+X->A) to change the execution policy of scripts:
Set-ExecutionPolicy RemoteSigned
This worked for my use case. The Unrestricted
flag can be used instead, but I haven’t researched about when I should do so. TO BE INVESTIGATED.