The Simple & Intuitive PowerShell
PowerShell is a task-focused scripting language developed primarily for system administration and automation, originally on Windows and now cross-platform. It follows an imperative, object-oriented, and pipeline-based paradigm, distinguishing itself by operating on structured objects rather than plain text (unlike Bash). The language is interpreted, supporting both an interactive shell and script-based execution. It employs a strong yet dynamic typing system, with deep integration into the .NET runtime. Positioned at a high level of abstraction, PowerShell is intended for orchestrating and automating existing systems and tools, rather than building standalone applications. Its design emphasizes simplicity, operational efficiency, composability, and system-level interoperability.
Fundamentals
History
- Origin and context of creation
- Problem it aimed to solve
- Evolution highlights (versioning, major shifts)
Toolchain & DevEx
- REPL support, script execution
- Formatters, linters, analyzers
- IDE and editor support (e.g., LSPs)
- Build systems, dependency managers
- Debugging and profiling tools
Syntax & Constructs
- PowerShell - Syntax & Execution Basics
- PowerShell - Variables and Nomenclature
- Studio/Expeditions/Programming/PowerShell/PowerShell - Error Handling
- PowerShell - Operators
- Studio/Expeditions/Programming/PowerShell/PowerShell - Flow Control and Loops
- PowerShell - Functions
- PowerShell - Data Structures
- Studio/Expeditions/Programming/PowerShell/PowerShell - Modules
- PowerShell - Object-Oriented Programming
- PowerShell - Reflection & Introspection
- PowerShell - Jobs & Parallelism
Recipes
Projects
Resources
Getting Started
- Official documentation
- Install guides, playgrounds
- Hello World tutorials
Book Recommendations
- PowerShell for SysAdmins by Adam Bertram | No Starch Press
- Learn PowerShell in a Month of Lunches by Travis Plunk, James Petty, Tyler Leonhardt, Don Jones and Jeffery Hicks | Manning | Amazon
- Mastering PowerShell Scripting by Chris Dent | Packt | Amazon
- PowerShell Cookbook by Lee Holmes | O'Reilly
- PowerShell Pocket Reference by Lee Holmes | O'Reilly
- PowerShell 7 for IT Professionals by Thomas Lee | Wiley | Amazon
Courses
- course 1
- course 2
Deep Dives
- Language reference
- Style guides and idioms
Community
- PowerShell User Groups
- PowerShell Tech Community
- DSC Community
- PowerShell.org
- PowerShell on StackOverFlow
- PowerShell on Reddit
- PowerShell Slack Group
- PowerShell Discord Server
- Spiceworks PowerShell Forum
PowerShell is an interactive Shell built on the .NET framework. On top of this, PowerShell supports advanced scripting and automation features. PowerShell has support to commands from the CMD and Unix shells.
Cmdlets in PowerShell
Commands in PowerShell are referred to as cmdlets (pronounced as command-lets). Each cmdlet in PowerShell follows a verb-noun pattern.
Command:
# General structure of cmdlets
# Retrieves the contents of a specified directory
Get-ChildItemOutput:
Directory: C:\Users\UniqueUser\Documents
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 01-10-2022 23:06 Custom Office Templates
d---- 31-10-2022 05:28 Dell
d---- 10-11-2022 21:38 IISExpress
d---- 03-12-2022 14:08 My Games
d---- 10-11-2022 21:38 My Web Sites
d---- 04-11-2022 05:44 PowerShell
d---- 04-11-2022 06:21 PowerToys
d---- 05-10-2022 21:27 Python Scripts
d---- 03-12-2022 21:27 Sound Recordings
d---- 13-11-2022 19:20 Visual Studio 2022Word-Capitalization in PowerShell
POWERSHELL IS NOT CASE-SENSITIVE. However, it is recommended to use the PascalCasing format when writing in PowerShell to aid in readability and to be uniform across the board. That being said, PowerShell will recognize and run the commands in both capital and small forms of the alphabet, so both Get-ChildItem and geT-cHiLdiTeM would fetch the contents of a specified directory.
PowerShell uses and recommends its scripting users to stick with a defined set of verbs, while the setting of noun is open for the scripting user. To get a list of all verbs used by PowerShell, simply type the Get-Verb cmdlet onto the PowerShell terminal.
Command:
# Retrieves a list of all verbs used by PowerShell
Get-VerbOutput:
Verb AliasPrefix Group Description
---- ----------- ----- -----------
Add a Common Adds a resource to a container, or attaches an..
Clear cl Common Removes all the resources from a container but does not..
Close cs Common Changes the state of a resource to make it inaccessible..
Copy cp Common Copies a resource to another name or to another container
Enter et Common Specifies an action that allows the user to move into a resource
Exit ex Common Sets the current environment or context to the..
Find fd Common Looks for an object in a container that is unknown..
Format f Common Arranges objects in a specified form or layout
Get g Common Specifies an action that retrieves a resource
Hide h Common Makes a resource undetectable
Join j Common Combines resources into one resource
Lock lk Common Secures a resource
Move m Common Moves a resource from one location to another
New n Common Creates a resource
--snip--PowerShell offers an extensive TAB completion feature that allows less typing and faster scripting. To save time even further, PowerShell allows the setting of various aliases that allow to define commonly used commands in a more shorter and rememberable format. The commands from the CMD and Unix shell land are actually stored in PowerShell as aliases.
Command:
# General structure of cmdlets
# Retrieves the contents of a specified directory
Get-ChildItem
ls
dirOutput:
Directory: C:\Users\UniqueUser\Documents
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 01-10-2022 23:06 Custom Office Templates
d---- 31-10-2022 05:28 HP
d---- 03-12-2022 14:08 My Games
d---- 10-11-2022 21:38 My Web Sites
d---- 04-11-2022 05:44 PowerShell
d---- 04-11-2022 06:21 PowerToys
d---- 05-10-2022 21:27 Python Scripts
d---- 03-12-2022 21:27 Sound Recordings
d---- 13-11-2022 19:20 Visual Studio 2022PowerShell cmdlets are positional in nature, meaning the parameters can be passed to the cmdlets in a sequential manner without explicitly specifying their name.
In the case of the Get-ChildItem cmdlet, the order of positional parameters are [-Path] [-Filter] [-Include] [-Exclude] [-Recurse] and so on.
Everything is an Object
PowerShell handles everything as an object from the .NET while most other shells handle them as text. This gives immense control over what is possible with the shell. This enables to use the full functionality of the .NET object library.
Command:
# Retrieves a list of all verbs used by PowerShell
"Hello World".LengthOutput:
11All cmdlets that generate an output are also created as objects. These objects can then be referenced and used downstream.
Administrators as First-Class Users
The Power of Piping
Getting Started
PowerShell Versions PowerShell Availability PowerShell Installation
PowerShell Command:
Command:
Get-Help Out-NullOutput:
NAME
Out-Null
SYNTAX
Out-Null [-InputObject <psobject>] [<CommonParameters>]
ALIASES
None
REMARKS
Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only
partial help.
-- To download and install Help files for the module that includes this cmdlet, use
Update-Help.
-- To view the Help topic for this cmdlet online, type: "Get-Help Out-Null -Online" or
go to https://go.microsoft.com/fwlink/?LinkID=2096792.Getting Comfortable
- Studio/Expeditions/Programming/PowerShell/PowerShell Basics
- PowerShell Control Flow
- PowerShell Error Handling
- PowerShell - Functions
- PowerShell Modules
Showcase
- Customizing the PowerShell Prompt
- PowerShell Showcase - Working with Objects
- PowerShell Showcase - Working with Output
- File and Drives Management with PowerShell
- PowerShell Showcase - Managing Processes and Services
- PowerShell Showcase - Working with UI Elements
- PowerShell Showcase - Managing CI-CD Pipelines
