Official PowerShell Documentation

repository·main·Indexed 25 days ago

https://github.com/microsoftdocs/powershell-docs

The central source for official PowerShell documentation, featuring cmdlet references for versions 5.1, 7.4, 7.5, 7.6, and 7.7, as well as conceptual learning articles. The content is organized by release version and module name, providing detailed guidance on core functionality, module availability, and advanced configuration such as custom Format.ps1xml files for console object display.

Tokens
132.6K
Snippets
321
Records
842
Agent score
66%

What's inside PowerShell Docs

  1. Overview of the Microsoft.PowerShell.Utility Module

    main
    The Microsoft.PowerShell.Utility module provides a wide range of fundamental cmdlets for common tasks in PowerShell. This includes data conversion (JSON, CSV, XML, HTML), object manipulation (adding members, sorting, grouping), string and file handling, debugging tools, and various formatting options for displaying output.
  2. What is PowerShell?

    main

    PowerShell is a cross-platform task automation solution designed for Windows, Linux, and macOS. It is composed of three primary pillars:

    1. Command-line Shell: A modern shell that operates on .NET objects rather than text, featuring tab completion, command prediction, aliases, and a pipeline for chaining commands.
    2. Scripting Language: A language built on the .NET Common Language Runtime (CLR) used for system management, CI/CD, and automation. It is extensible via functions, classes, scripts, and modules, and has built-in support for CSV, JSON, and XML.
    3. Configuration Management: Provided through PowerShell Desired State Configuration (DSC), which allows for managing enterprise infrastructure as code using declarative configurations.
  3. Overview of the PowerShell-Docs repository

    main
    The microsoftdocs/powershell-docs repository contains the official PowerShell documentation. This includes cmdlet references for various PowerShell versions (5.1, 7.4, 7.5, 7.6, 7.7) and conceptual articles. The reference content in the versioned folders is used both to generate the official Docs website and to create the updatable help used directly within PowerShell.
  4. Explore PowerShell About Topics

    main
    PowerShell provides a comprehensive set of 'About' topics that serve as built-in documentation for the language, engine, and core concepts. These topics cover everything from basic syntax (operators, variables, loops) to advanced features (classes, remote sessions, error handling, and providers). You can access these topics to understand how specific components of PowerShell function.
  5. Use Get-Item to retrieve items from providers

    main

    The Get-Item cmdlet retrieves an item or multiple items from a specified location. It is designed to work across different PowerShell providers (e.g., FileSystem, Certificate, Registry, Env, etc.).

    Key Behaviors:

    • Path vs. LiteralPath: Use -Path when you want to allow wildcard characters (like * or ?). Use -LiteralPath when you want the path to be interpreted exactly as typed, without any wildcard processing.
    • No Recursion: Get-Item retrieves only the specific item(s) requested. It does not have a -Recurse parameter. To retrieve the contents of an item recursively, use Get-ChildItem instead.
    • Registry Usage: To navigate the registry, use Get-Item to retrieve registry keys, and use Get-ItemProperty to retrieve the actual values and data stored within those keys.
    • Aliases: You can use the alias gi instead of Get-Item.
  6. Get-Item cmdlet overview

    main

    The Get-Item cmdlet retrieves the item at a specified location. It is used by PowerShell providers to navigate various data stores (e.g., FileSystem, Certificate, Registry).

    Important Behavior:

    • By default, Get-Item retrieves the item itself, not its contents.
    • To retrieve the contents of an item, you must use a wildcard character (*).
    • For Registry providers, Get-Item retrieves registry keys and subkeys; use Get-ItemProperty to retrieve registry values and data.
    Get-Item .
  7. Explore PowerShell core concepts using About topics

    main

    The about: drive in PowerShell provides access to a collection of help topics that cover fundamental PowerShell concepts. You can use these topics to learn about core language features, data types, and operational mechanics.

    Commonly available topics include:

    • about_Alias_Provider: Information on the Alias provider.
    • about_Aliases: Details on using aliases.
    • about_ANSI_Terminals: Information regarding ANSI terminals.
    • about_Arithmetic_Operators: Usage of arithmetic operators.
    • about_Arrays: How to work with arrays.
    • about_Assignment_Operators: Details on assignment operators.
    • about_Automatic_Variables: Information on built-in automatic variables.
    • about_Booleans: Usage of Boolean values.
    • about_Break: How to use the break statement.
  8. Use the Registry provider to manage Windows Registry

    main

    The Registry provider allows you to get, add, change, clear, and delete registry keys, entries, and values directly within PowerShell.

    Note: This provider is only available on PowerShell running on Windows.

    Default Drives

    The provider exposes the registry via two default drives:

    • HKLM: maps to HKEY_LOCAL_MACHINE
    • HKCU: maps to HKEY_CURRENT_USER

    Supported Cmdlets

    You can use standard PowerShell cmdlets to interact with the registry, including:

    • Navigation: Get-Location, Set-Location (and alias cd)
    • Item Management: Get-Item, Get-ChildItem, Invoke-Item, Move-Item, New-Item, Remove-Item
    • Property Management: Clear-ItemProperty, Get-ItemProperty, New-ItemProperty, Remove-ItemProperty, Set-ItemProperty
    • ACL Management: Get-Acl, Set-Acl
  9. Get-Command cmdlet overview

    main

    The Get-Command cmdlet retrieves all commands installed on the computer, including cmdlets, aliases, functions, filters, scripts, and applications. It pulls data from PowerShell modules and system-available commands.

    Key behaviors:

    • Automatic Module Loading: If you provide an exact command name without wildcards, Get-Command automatically imports the module containing that command. This behavior is controlled by the $PSModuleAutoLoadingPreference preference variable.
    • Scope: By default, it retrieves commands from installed modules. To limit results to only those commands currently imported into your active session, use the -ListImported parameter.
    • Applications: Using Get-Command * retrieves all command types, including non-PowerShell files found in your $Env:PATH (listed as the Application command type).
    • Data Source: Unlike Get-Help, which relies on help topics, Get-Command retrieves its data directly from the command code itself.
  10. Get-Command: Overview and basic usage

    main

    The Get-Command cmdlet (alias gcm) retrieves all commands installed on the computer, including cmdlets, aliases, functions, filters, scripts, and applications. It can pull commands from PowerShell modules or from the system's PATH environment variable.

    Key behaviors:

    • Automatic Module Importing: Using an exact command name without wildcards automatically imports the module containing that command (controlled by $PSModuleAutoLoadingPreference).
    • Version Information: Starting in Windows PowerShell 5.0, results include a Version column by default.
    • Command Types: Includes Cmdlet, Alias, Function, Filter, Script, and Application (non-PowerShell files in $Env:PATH).
  11. Use Updatable Help cmdlets

    main

    PowerShell uses an Updatable Help system to ensure you have the latest help topics locally. The system relies on three primary cmdlets:

    • Update-Help: Downloads the newest help files from the internet or a file share and installs them on the local computer.
    • Save-Help: Downloads the newest help files from the internet and saves them to a filesystem directory or file share (useful for offline/enterprise deployment).
    • Get-Help: Displays help topics at the command line using local files, or shows auto-generated help/online help if local files are missing.
  12. Get-Command

    main

    The Get-Command cmdlet retrieves all commands installed on the computer, including cmdlets, aliases, functions, filters, scripts, and applications. It pulls data directly from the command code.

    Key behaviors:

    • Automatic Module Loading: Using the exact name of a command (without wildcards) automatically imports the module containing that command. This behavior is controlled by the $PSModuleAutoLoadingPreference preference variable.
    • Scope: Without parameters, it returns cmdlets, functions, and aliases. Using Get-Command * retrieves all command types, including non-PowerShell applications found in the $Env:PATH environment variable.
    • Imported Commands: To see only commands currently imported into your session, use the -ListImported parameter.
    • Version Information: In Windows PowerShell 5.0 and later, results include a Version column by default, as the CommandInfo class includes a Version property.
    # Get-Command
    
    ## SYNOPSIS
    Gets all commands.
    
    Aliases: `gcm`