liveBook · Manning

PowerShell profile

As explained in Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

A PowerShell profile is a user-specific script that runs when a PowerShell session starts and can configure the session environment.

A PowerShell profile is a script that runs when a hosting application starts a session. Use it to make recurring administrative setup automatic instead of retyping commands. section 26.1.1

A profile can prepare a session by:

  • Loading frequently used modules, such as ActiveDirectory or DBATools. section 26.1.1
  • Changing to a preferred starting directory, such as the root of the C: drive. section 26.1.1
  • Defining reusable functions, including a custom prompt function. section 26.1.1 section 26.1.2
  • Applying settings that may depend on the host; console-specific changes can fail in VS Code or Windows Terminal. section 26.1.1

A practical startup profile

A profile can import commonly used modules and place the session where work begins. Importing ActiveDirectory also makes its AD: PowerShell drive available immediately. Add only settings that work in the hosting applications you use. section 26.1.1

A more informative prompt

Define a prompt function in the profile to display the current time and computer name, producing a prompt such as 6:07 PM [CLIENT01]:>.

Import-Module ActiveDirectory
Import-Module DBATools
cd c:\

Inspect a compact example of module loading and starting-directory setup. section 26.1.1

How Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS covers it

How deep it goes
Explains startup behavior, common customizations, host compatibility, and prompt functions without detailing every profile path.
Examples
Demonstrates module imports, directory changes, custom prompts, window titles, and shell color settings.
What you can do after
Operate/configure repeatable startup behavior by placing compatible commands in a profile script.
How it connects
Connects profiles with hosting applications, modules, functions, prompts, and PowerShell drives.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS. The section links point to the parts of the book it draws on.