Making It Yours

Why a script will or will not run, your profile, short names, a prompt in your colors, and installing apps and modules.

Updated

Running Scripts

  1. Why a Script Won't Run: The Execution Policy (Apprentice): PowerShell's execution policy decides which script files may run; Get-ExecutionPolicy -List shows who set it, RemoteSigned for your own account lets your scripts run, and Unblock-File clears a downloaded script you've read and trust.

Your Setup

  1. Your Profile (Apprentice): Your profile is a script PowerShell runs every time it starts, at the path in $PROFILE, so the variables, short names and settings you put in it are ready in every window, and dot-sourcing it loads a change into the window you're in.
  2. Aliases and Small Functions (Apprentice): Set-Alias gives a command a short name of your own, and when the job needs a parameter's value or more than one step, a small function does it instead; both go in your profile so they're there in every window.
  3. A Prompt in Your Colors (Journeyman): PowerShell's prompt is a function named prompt that runs before every command you type, so you can write your own that shows the folder's name, the time and colors from $PSStyle, and keep it in your profile.

Installing

  1. Installing Apps and Modules: winget and the PowerShell Gallery (Apprentice): winget finds, installs and updates Windows apps by name, and the PowerShell Gallery does the same for modules, PowerShell's add-on commands, with Find-PSResource and Install-PSResource; because anyone can publish a module, check who made one before you install it.

Exercise: Your Toolkit, Version 1

  1. Exercise: Your Toolkit, Version 1 (Apprentice): Build the first version of your own PowerShell toolkit, a file with an alias, three small functions and a prompt in your colors, answer five questions about running scripts and installing tools, and let a Pester check try every shortcut for real.