Create Your Profile Script with One Line

Posted
Comments None

For a PowerShell beginner, I would make the following suggestions:

  1. Use the console, not the ISE
  2. Change the font to Consolas
  3. Use Windows 10 or at least upgrade to PowerShell 5

Additionally, the first thing you’ll need to do is set the execution policy on your machine. You probably want to start out with “RemoteSigned.” To change it, run a new instance of PowerShell as Administrator. Then execute:

Set-ExecutionPolicy RemoteSigned

It will ask you to confirm. Note that this is a system-wide setting. If you start an un-elevated instance of PowerShell, and make the change in your Administrator PowerShell instance, you can see the setting change in your normal window by running

Get-ExecutionPolicy

For nearly any “Set” command, there is a corresponding “Get” command. Learn this well as you start out: “Get it before you set it.”

Now, we need to see if a profile script exists yet on this machine. There is a built-in global variable for the location of your profile script, $profile. To see if one exists, run

Test-Path $profile

Either true or false will be returned. If true was returned, skip the next part or you’ll overwrite any changes you’ve made previously. Otherwise, go ahead and create a profile script now with

New-Item -path $profile -type file -force

When you add the -force switch to New-Item, it creates any missing directories in the path as well as the final item. Now, you can edit the script graphially with

notepad $profile

You might consider adding some aliases or a function to customize your command prompt.

Author

Comments

There are currently no comments on this article.

Comment

Enter your comment below. Fields marked * are required. You must preview your comment before submitting it.





← Older Newer →