However, it’s not just a scripting language.
If you find yourself using it as a command line shell it may be useful to store your functions and customizations in a profile that gets loaded every time you load the Console.
The first thing we do here is check if we already have a profile. There is an automatic variable, $Profile, that stores the fully qualified location of the PowerShell profile. An easy way to check if any profile exists is to use the Test-Path cmdlet on the $Profile variable.
Test-Path $Profile
![PS-18](https://msdynamicsnavashwinitripathi.files.wordpress.com/2016/06/ps-18.jpg)
As you can see no profile file yet created for me, so we will create one, we can easily do that with the New-Item cmdlet.
New-Item –Path $Profile –Type File –Force
Using the force parameter will cause a profile to be created even if already we have one. This means our old profile will be overwritten and new will be created.
![PS-19](https://msdynamicsnavashwinitripathi.files.wordpress.com/2016/06/ps-19.jpg)
Profile can be edit using notepad, which can be easily started using PowerShell.
notepad $Profile
![PS-20](https://msdynamicsnavashwinitripathi.files.wordpress.com/2016/06/ps-20.jpg)
You can put any commands, functions, alias’s and even module imports into your PowerShell profile.
I normally work on PowerShell for Navision so I would prefer loading module whenever I launch the PowerShell command, so I include my cmdlets for loading the same in my profile.
![PS-21](https://msdynamicsnavashwinitripathi.files.wordpress.com/2016/06/ps-21.jpg)
Save the Profile and close the PowerShell. Next time I launch PowerShell this Module get loaded for me by default.
Finally, I would like to also have some customizations to the console. One is it basically determines if you have opened an elevated PowerShell console and changes the font colour, this way I will always remember that I am running with elevated privileges.
Let us Save the Profile and check the effect of this Profile.
![PS-22](https://msdynamicsnavashwinitripathi.files.wordpress.com/2016/06/ps-22.jpg)
That’s all for today.
I will come up with more stuffs in my upcoming posts.
Till then keep practicing and stay tuned for more details.
No comments:
Post a Comment