hn.today

I can't believe PowerShell is good

spacebar.news55 points68 comments
Screenshot of I can't believe PowerShell is good

A writer recounts switching from Bash and ad-hoc languages to PowerShell 7 and explains why it became a go-to tool for cross-platform scripting and automation. The core claim is that PowerShell’s built-in cmdlets, strong parameter handling (Param blocks), native data types, and object-oriented design remove much of the boilerplate and external-dependency pain common in POSIX shell scripts. PowerShell 7 runs on Windows, macOS, and Linux (invoked as pwsh), understands ~ and $HOME paths, integrates with .NET when needed, and is well-supported in Visual Studio Code. The modern release also removed legacy cruft like the curl alias that confused users of the real cURL.

Concrete examples show how those features help in practice: a simple MP3 downloader that exposes a typed URI parameter; an installer for removing unwanted browser features that manipulates the Windows registry via PowerShell’s virtual HKLM: drive using Test-Path and Get-ItemProperty and downloads .reg files with Invoke-WebRequest before invoking reg.exe; and a Tumblr-to-Eleventy migration script that uses Invoke-WebRequest, ConvertFrom-Json/ConvertTo-Json, Expand-Archive, and file cmdlets to preserve metadata. PowerShell’s native web, JSON, file, and registry capabilities let the author replace clumsy Bash stacks or heavier languages for many real tasks.

Read on spacebar.news68 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.