Search This Blog and Web

Monday, October 12, 2015

What's in my Power Shell profile ?

Ed Wilson aka "The Scripting Guy" from Microsoft ran a series of posts in which he wrote about what different users have in their profiles. I was also one of those who replied to that email and he kindly did mention me in his blog.

Today, I want to share what's in my profile. I've customized it a bit more since then.
Here' what it has :
  • Change Error color to Gray from default red. It stresses me to see RED RED on the prompt.
  • Changing the location to my scripts folder to :  Easily call my common scripts, Prevent accidental changes to system32 folder.
  • Checking if I've launched Power Shell as an Admin or not.
  • Customizing in-built PROMPT function to show ADMIN/DBG mode and increment command number after each command run.

Want to know what Power Shell MVP's have ? See here.

If you don't know about profile, in simple terms I'll try to explain.
It's an auto-loading PS1 file which runs each time Power Shell starts. Whatever is written in it is executed and then you can see prompt. the environment variable $Profile tells you the path of the file.

To bypass loading profile, powershell.exe has a parameter called -NoProfile. It's a best practice to use this. If an attacker has control of your system, he can change PROFILE and run arbitrary code. Also, your code may behave differently if someone has changed some functions in it.

Featured Post

Timeout problem in Backup-SQLDatabase cmdlet in SQLPS module

Power Shell is for managing all types of technologies be it SQL, EXchange, Lync, Office etc.( just name it ) These technologies usually cr...