- Proof of Concept
- My Profile
- Making it Your Own
- Related Links
Share my PowerShell profile with the world in a digestible manner. Explain the main functions, how you can install my profile, and optionally contribute.
You’re going to learn a lot but you’re also expected to come to the table with a few things. If you plan to follow along, be sure you have the following:
- Windows 10 (tested on 1903 and newer)
- Windows PowerShell (tested on 5.1 and 7.0), run as administrator
Profiles are loaded every time you launch PowerShell. You can add fancy functions to your profile to make your life easier (such as Get-CatFacts 🐱).
PowerShell profiles are unique—they’re personal. They’re living things, just as your needs change over time, I expect your PowerShell profile will as well, heck mine sure has (just look at my commit history).
Realistically, I see basic functions like setting the default directory when you launch PowerShell, importing some modules, setting some aliases being universal. You may not need any of these, just like you don’t need a PowerShell profile at all, but we’re talking about the quality of life here, not needs.
PowerShell profiles are a rabbit hole for sure. Every blog post I’ve seen goes into (excruciating) detail on the different types of profiles, which one you’ll need, etc. I’ll save you the time (and handle it for you), but if you’re interested, go check out the official PowerShell docs.
Proof of Concept
Before we dive in, here’s a taste. Try the following:
- Open PowerShell as administrator
Create your profile by typing
You’ll get an error if the file already exists. This is expected.
- Copy the code block below into your
Set-Location $env:TEMP Import-Module PSReadLine -Verbose Set-Alias ll Get-ChildItem -Option AllScope
& $profileand hit enter. There you go, there’s your first PowerShell $profile.
What happens? What did you expect to happen?
My personal PowerShell profile is made with sugar, splice, and everything nice.
This is where I tell you to be sure you’re aware of what you’re downloading from the internet. You can view the source on GitHub and inspect the code prior to downloading/executing anything described in this post. I do eventually plan on making my profile a signed PowerShell module to make it easier to download and distribute.
If you want to just get started with copying my homework run the following command in PowerShell as administrator:
iex ((New-Object Net.WebClient).DownloadString('https://github.com/tseknet/PowerShell-Profile/raw/master/install.ps1'))
You’ll see verbose messages scrolling by explaining what is currently executing. You should also see a few prompts along the way, such as to allow a new NuGet provider. This is expected.
See fonts below if you see missing characters in your prompt.
I can’t take all the credit. The following (awesome) modules will be installed by default:
- posh-git: Integrates Git and PowerShell by providing Git status summary information
- oh-my-posh: Theme engine for PowerShell
- Get-ChildItemColor: Provides colorization of outputs of
Get-ChildItemCmdlet of PowerShell
- PSWriteHTML: Output PowerShell commands to a formatted HTML page
By default, my profile installs Powerline fonts from GitHub to enable custom characters in the console. You may see multiple popups to install fonts. This is expected.
Once the font(s) are installed, you may see multiple missing characters. To fix this, see the instructions below.
The default Powerline font that this theme uses is
DejaVu Sans Mono for Powerline. This can be modified in
Change your PowerShell font to
DejaVu Sans Mono for Powerline in the settings JSON file.
- Right-click the title bar of the PowerShell console
- Select Properties
- Select the Font tab
DejaVu Sans Mono for Powerline
- Click OK
You should now see your fully customized prompt 🎉
Here’s a high-level summary of some functions that my profile script provides:
- Auto-update: Download the latest profile file from GitHub if necessary
- Set the PowerShell Window Title with useful information such as elevation and version
- Install and import modules listed above
historycommands for better results
- Download and set my personal
oh-my-poshtheme module, TsekNet.psm1
- Install Powerline fonts using
- Set the default location
Output functions made by the profile to the console
…and much more!
Errors will be shown in the console. Type
$Error to see the latest error message if necessary for troubleshooting.
Making it Your Own
As mentioned in the background section, PowerShell profiles are unique. Feel free to fork my profile from GitHub, and modify it to fit your needs.
As an example, you can point the auto-updater function
Import-GitRepo to your repository here.
I’ve tried to break out functions that you may want to modify at the bottom of the script, including cmdlets with configurable options.
By leveraging PowerShell profiles, you can make your every day repetitive tasks easier.
Wish you could get the weather at any moment from PowerShell? Make a function, add it to your profile. Wish you could get random comics? Make a function, add it to your profile.
I invite you to open a pull request if you found any issue with my PowerShell profile. Got a cool function you’re using in your profile? Leave a comment below!
Now get out there and make PowerShell do the work for you ✨
- Jaykul’s Profile on GitHub
- PowerShell Docs
- How To Uniquify Your PowerShell Console
- Understanding the Six PowerShell Profiles