Windows Tip Sheet
"Clean" and Mean PowerShell Sessions
Another Profile Tip: Load PowerShell without all those extra doodads to get in the way.
A few columns ago
- By Jeffery Hicks
, I showed you how I added a prompt to my profile asking whether I want to load it or not. Well, there's another way to avoid loading a profile.
When you start PowerShell from the command line, it offers up a -noprofile switch. If you have a CMD window open, just type:
Your prompt will change to a PowerShell prompt, indicating you are in PowerShell. You likely won't have the same screen configuration as you have when launching PowerShell from the menu shortcut, but it's PowerShell nonetheless.
While you're at it, you might prefer to add the -nologo parameter as well; this switch suppresses the PowerShell version banner.
Even though you've started PowerShell without your profile, the $Profile variable is still at work here. If you decide later that you want to use the functions and commands from your profile, you can invoke it at any time by typing this:
PS C:\Users\Jeff > . $profile
When you are finished with PowerShell, simply type Exit to return to the CMD shell.
If you find yourself often needing to be in PowerShell but don't want your profile to load, I suggest creating a shortcut. Set the command parameter to Powershell -noprofile and name it as you want. Then edit the properties to configure the window size, font, buffers, colors and anything else you prefer. Now you'll have a "clean" PowerShell session just the way you want it.
Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.