Object Features in pwsh

PowerShell (pwsh) is fundamentally different from traditional command-line shells like Bash or Zsh. While other shells primarily deal with streams of text, PowerShell is built around objects — a core design that enhances scripting efficiency, data manipulation, and overall readability. This object-oriented nature makes PowerShell one of the most powerful tools for system administration, data processing, and cross-platform automation. 🧠 Core Concept: Objects, Not Text In traditional shells, command output is plain text. To extract specific data, you rely on utilities like grep, awk, or sed, often combined with regular expressions. This approach is fragile — if the output format changes, your script can break. ...

October 27, 2025

Install PowerShell (pwsh) on Linux

PowerShell (known as pwsh in its cross-platform version, PowerShell 7+) is Microsoft’s open-source shell and scripting language. Installing it on Linux allows you to run PowerShell scripts, cmdlets, and modules alongside native Linux tools. We’ll use WSL (Windows Subsystem for Linux) — with Ubuntu 24.04 LTS — as the main example, though the process is similar on other distros. 🧩 Prerequisites WSL Installed: Ensure WSL is set up (Windows 10 2004+ or Windows 11). To install WSL, open PowerShell as Administrator and run: ...

October 24, 2025

New Operators in PowerShell (pwsh)

PowerShell 7 (and later, pwsh) introduced several modern operators that enhance scripting efficiency and align PowerShell more closely with other programming languages. Included Operators && and || — Pipeline chain operators ?? and ??= — Null-coalescing operators ?: — Ternary operator 1. Pipeline Chain Operators (&& and ||) Introduced: PowerShell 7.0 Purpose: Execute commands conditionally based on the success or failure of the previous command — similar to Bash. Behavior && — Executes the next command only if the previous command succeeds (exit code 0). || — Executes the next command only if the previous command fails (non-zero exit code). Key Points Success is determined by $LASTEXITCODE for external commands (e.g., hugo, git). Works with both PowerShell cmdlets and external commands in pwsh. Examples Check Hugo and Deploy: ...

October 24, 2025

Get a list of AD users

This guide demonstrates a PowerShell script to query Active Directory for users, filter them by a specific pattern, extract relevant information, and then export the results to a CSV file. This is particularly useful for auditing or reporting purposes. PowerShell Script to Get Filtered AD Users The following script connects to your Active Directory domain, filters user accounts starting with “PS”, extracts their account number (trailing digits from SamAccountName), account name, first name, and last name, and then outputs the results to both the console and a CSV file. ...

October 20, 2025

How to install winget

winget is the Windows Package Manager, a command-line tool that simplifies the process of managing software on Windows. Here’s how you can install it. Usually, winget could be installed from Microsoft Store. However, if not found there, use github to install. Install from GitHub In some corporate environments, access to the Microsoft Store may be restricted. In such cases, you can download and install winget directly from the official GitHub repository. ...

October 20, 2025

How to install pwsh

Installing pwsh, the modern cross-platform PowerShell, is a straightforward process. This guide will walk you through three key methods to get PowerShell up and running on your Windows machine. The latest stable version is v7.5.3, at the writing of today. 1. Check Your Current PowerShell Version Before installing a new version, it’s a good idea to see what version of PowerShell you’re currently running. Open your existing PowerShell terminal and enter the following command: ...

October 20, 2025

What is PWSH

pwsh is the executable name for modern, cross-platform PowerShell, starting from PowerShell Core 6. It represents a significant evolution from the original Windows PowerShell. The History of PowerShell and the Rise of pwsh PowerShell was first released in 2006 as Windows PowerShell, a powerful scripting language and command-line shell for Windows, built on the .NET Framework. For years, it was exclusively a Windows tool. A major shift occurred in 2016 when Microsoft announced PowerShell would become open-source and cross-platform. This led to the creation of PowerShell Core, built on .NET Core (now just .NET), which can run on Windows, macOS, and Linux. To differentiate this new version from its Windows-only predecessor, the executable was named pwsh. ...

October 13, 2025