I can not consider EnergyShell is definitely good

Microsoft makes a lot of dangerous software program. That consists of many elements of Windows, from the primary email application being a web wrapper to the ever-present Copilot buttons. As such, it is all the time a shock to me after I discover a Microsoft product that improves my life in some respect, particularly when it is one thing that got here from Windows.
I by no means paid a lot consideration to EnergyShell, the command-line shell and scripting device that first arrived in 2006, and have become a bundled utility with the discharge of Windows 7. For the time interval I used Windows as my most important desktop working system, I largely caught to the Command Prompt and Batch scripts, or Bash in WSL or Python for extra complicated duties. The trendy model of EnergyShell is cross-platform, and can be put in on Mac and Linux.
Earlier this 12 months, I wanted to be taught EnergyShell scripting for one Windows-related mission, and I’ve tried it out just a few extra occasions on Mac. It has rapidly turn out to be certainly one of my favourite instruments for automation and scripting—taking over jobs that I might have in any other case tried to do with Node.js, Shortcuts, macOS Automator, or heaven forbid, Bash scripts.
I get it now. EnergyShell is nice, even in case you do not use it as your shell, and even in case you’re on Mac or Linux.
Bashing my head towards the wall
The commonest approach to run a sequence of instructions on Linux, macOS, and different Unix-based environments is with a Bash script. They are additionally referred to as shell scripts, though they’re not technically the same thing, as a result of they’re additionally utilized by different shells like Z Shell (zsh).
Here’s an instance Bash script that asks you for a media URL, after which makes use of the yt-dlp application to put it aside as an MP3 audio file to your Desktop folder:
#!/bin/bash
echo -e "Enter a URL: "
learn url
cd ~/Desktop
yt-dlp -x --audio-format mp3 "$url"
echo "Done!"
Bash scripts are high quality for simply operating a collection of instructions. You can use variables and loops, code you utilize greater than as soon as can go in a perform, and there is even restricted help for information varieties like arrays. They also can generally work on all kinds of {hardware} and working programs.
For something barely extra sophisticated, Bash scripting is simply the worst. There are virtually no “built-in” capabilities—you might be supposed to make use of POSIX commands for widespread duties, like file operations or parsing textual content. Anything past that relies on exterior instruments, like cURL or Wget for retrieving internet content material, several different applications for accessing the clipboard, and jq for studying JSON information. You may additionally want boilerplate code for parsing options and parameters.
It can also be surprisingly troublesome to make a Bash script that works reliably on different folks’s computer systems. Some folks would possibly attempt your script in a distinct shell that does not interpret scripts in the identical approach—that is why the command for installing Homebrew begins with calling the bash shell particularly, and lots of different instruments use the identical trick. Someone would possibly solely have cURL put in for fetching internet content material, or solely Wget, or each, or neither! You cannot assume each system may have the identical fundamental set of POSIX instructions, and even the sudo command, as I learned a few months ago.
The limitations of Bash scripting normally pushed me in the direction of precise programming languages, even for duties that did not strictly want them. Python is likely to be one of the best different, however its lack of curly braces makes me unhappy. I write a whole lot of JavaScript code, so Node.js is an possibility, however I’ve to place await operators in all places for system operations and hope that I’m not installing malware when extra dependencies are wanted.
Hello, EnergyShell
Like many different merchandise from Microsoft (and Google), EnergyShell is definitely two different things with related names. The one it is best to use is EnergyShell 7, additionally referred to as EnergyShell Core, which is the fashionable cross-platform model primarily based on .NET Core. The different one is Windows EnergyShell (v5.1 and under), which relies on .NET Framework and never actively developed. Windows 11 nonetheless only includes Windows PowerShell, and never EnergyShell 7.
EnergyShell 7 is a free download on Windows, Mac, and Linux. On my Mac computer systems, I used Homebrew to install it, after which I can run it with pwsh within the Terminal.
The fundamental premise of a EnergyShell script is not a lot totally different than a Bash script. It’s a listing of instructions, both supplied by the shell or the underlying system, with the flexibility to make use of extra capabilities and key phrases (like if, foreach, or attempt/catch) as wanted.
EnergyShell has many built-in instructions, referred to as “cmdlets” (pronounced “command-lets”), and you’ll install more or make your individual. The names for many of them are verb-noun pairs, like Set-Location as a substitute of POSIX’s cd, Clear-Host as a substitute of cls, and Remove-Item as a substitute of rm.
Here’s that MP3 downloader once more, however now as a EnergyShell script:
Param(
[Parameter(Mandatory = $true)][uri]$url
)
Set-Location -Path ~/Desktop
yt-dlp -x --audio-format mp3 "$url"
Write-Host "Done!"
The cool half in that script is the Param block, which makes use of PowerShell’s built-in parameter support to outline “url” as a compulsory URI input. EnergyShell will ask for that URL when the script begins, much like the Bash instance, whereas additionally permitting a -url parameter on the script instead enter methodology.
You may even run EnergyShell’s built-in Get-Help command on the script, which exhibits the checklist of parameters with their information varieties, identical to Get-Help would for a built-in command.

This similar performance in Bash would want a whole lot of boilerplate code with getparams and varied if statements. EnergyShell handles all that for you.
In case you have been questioning, that Unix-style ~/Desktop path works in EnergyShell on all platforms. Even although Windows makes use of paths with backslashes on the system degree, EnergyShell can convert them as wanted—native system instructions won’t, although, except you utilize the Convert-Path cmdlet first. Just like in Bash, the tilde (~) character is an alias for the house listing, or you should use the $HOME variable that PowerShell supports on all platforms.
EnergyShell has native help for integers, strings, arrays, and hash tables. That’s particularly helpful when parsing content material from internet APIs, as a result of EnergyShell can convert to and from JSON. It’s additionally totally object-oriented, and you’ll create custom objects or name .NET capabilities if wanted.
You can use any textual content editor to write down EnergyShell scripts, identical to with Bash. If you occur to make use of Visual Studio Code, it gives syntax completions, definition tracking, and linting support for EnergyShell, amongst different options.
The trial run
My first actual mission with EnergyShell was Just the Browser, a mission that goals to take away AI options, monitoring, and different undesirable performance from desktop internet browsers. The installer for Mac and Linux is a Bash script, so it made sense to make the Windows version as a EnergyShell script.
The installer’s job is to examine which browsers are current on the pc, after which present an “Update settings” menu merchandise for every browser. When that merchandise is chosen, the script downloads and installs a Windows registry file containing the browser settings. If the settings have been put in, the script exhibits an extra “Remove settings” possibility within the menu to reverse the method.

This works by creating a listing object with a .NET ListTest-Path and Get-ItemProperty cmdlets, like this:
if (Test-Path "HKLM:SOFTWAREPoliciesGoogleChrome") {
$IfAiSettingExists = (Get-ItemProperty -Path "HKLM:SOFTWAREPoliciesGoogleChrome").AIModeSettings
}
There are just a few cool issues in that snippet. You might need observed that registry path seems extra like a file path on a drive referred to as “HKLM” than the same old Windows Registry hierarchy, which seems like this:
HKEY_LOCAL_MACHINESOFTWAREPoliciesGoogleChrome
EnergyShell creates a virtual drive for the Windows Registry, permitting you to get, add, change, clear, and delete registry keys as in the event that they have been information in any file system. That similar Test-Path cmdlet would additionally work for checking if a sure file was in my Downloads folder. You do not need to learn to use information and find out how to use registry keys, as a result of they’re the identical factor in EnergyShell.
There are different digital drives in EnergyShell, just like the one for certificate storage in Windows, and you’ll even create your own. If you are bored with typing an extended path in your shell or scripts, make a digital drive that factors to it! You may even name it FART: if you would like.
That script additionally has to obtain the .reg information for configuring internet browsers. Here’s a simplified model of the method for Google Chrome:
$GoogleChromeInstallRegistry = "https://raw.githubusercontent.com/corbindavenport/just-the-browser/main/chrome/install.reg"
Invoke-WebRequest $GoogleChromeInstallRegistry -OutFile "$env:LocalAppDatachrome.reg"
$ChromeInstall = Start-Process "reg.exe" -ArgumentList "import `"$env:LocalAppDatachrome.reg`"" -WindowStyle Hidden -Wait -PassThru
This makes use of the Invoke-WebRequest cmdlet to obtain the registry file from the supplied URL, and shops it quickly within the person account’s AppData folder. It then begins the reg.exe command in a hidden window, tells it to import the file that was simply downloaded, and waits till the command is accomplished. EnergyShell may modify the keys immediately, however I needed them to be in a separate file that may be imported manually, since not everybody desires to make use of the automated installer.
The Invoke-WebRequest cmdlet works like Wget or cURL on a Mac or Linux system, permitting you to obtain internet content material in your script. That’s one other characteristic constructed into EnergyShell on all platforms that I ceaselessly want in Bash scripts.
I needed the installer to work in older variations of Windows EnergyShell, so it may run on older PCs with out first upgrading the EnergyShell model. That solely required just a few alterations, like this command that permits TLS v1.2 earlier than utilizing Invoke-WebRequest, as a result of it used to not be enabled by default:
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12
For one other mission, I used to be experimenting with merging my outdated Tumblr weblog into my most important private web site, which makes use of the Eleventy static site generator. There have been no present instruments for that, so I created a “Tumblr to Eleventy” PowerShell script.
The script has two most important inputs: Tumblr’s archive export, which is a bunch of HTML and media attachments in a ZIP file, and the Tumblr API. It makes use of Invoke-WebRequest and ConvertFrom-Json to examine the API and iterate by all posts on the weblog, Expand-Archive to extract the ZIP file, and cmdlets like Copy-Item and New-Item to create a brand new file construction prepared for an Eleventy web site.
The most necessary half was holding all of the metadata from the unique Tumblr put up, together with the title, permalink, publish date, and tags. The script does that by making a customized object with all the information, then turns it into Eleventy-friendly JSON format with the ConvertTo-Json cmdlet:
$OutputJson = Join-Path -Path $OutputPath -Little onePath "index.json"
$PostMetadata = [PSCustomObject]@{
title = $Post.title ? $Post.title : $Post.abstract
permalink = ($Post.post_url -replace $Post.weblog.url, "/") + "/index.html"
date = [DateTimeOffset]::FromUnixTimeSeconds($Post.timestamp).UtcDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ")
tags = $tag ? (@($tag) + $Post.tags) : $Post.tags
tumblr_id = $Post.id
tumblr_url = $Post.post_url
tumblr_short_url = $Post.short_url
tumblr_blog_name = $Post.blog_name
}
$PostMetadata | ConvertTo-Json -Depth 1 | Set-Content -Path $OutputJson -Encoding UTF8
The $Post variable incorporates the response from the Tumblr API, so that is simply mapping that information to the keys that Eleventy expects. For instance, the API generally put my put up titles because the abstract as a substitute of the title, so the script checks .title first and makes use of .abstract because the fallback. Tumblr supplied the publish date and time for every put up in Unix time, which EnergyShell can convert to the UTC format required by Eleventy.

I most likely would have used Node.js for this if it wasn’t EnergyShell, since Node does have built-in web requests and file handling. However, it will have wanted exterior dependencies for easy duties like unzipping the archive (both calling the system’s unzip or utilizing a JS-native library), in addition to await statements everywhere. I did not find yourself shifting my weblog, however hopefully another person will discover that script helpful.
I’m nonetheless getting the cling of EnergyShell scripting, however I’ve come away extra impressed with it after each mission. It’s cross-platform, extra predictable and reusable than Bash scripts, and comparatively straightforward to grasp. I can not consider this got here out of the identical firm as Copilot.
Of course, none of this issues in case you do scripting and automation the cool approach, with Claude or one other AI chatbot taking the wheel. The bot can do the pondering and testing for you. However, I like studying issues, and I’m making an attempt my greatest to forestall my mind from atrophying. An area Gemma 4 mannequin in LM Studio did assist me with troubleshooting when internet searches failed, however the overwhelming majority of my scripting up to now has been lovingly hand-crafted.
If you are thinking about studying find out how to use EnergyShell, there are many on-line guides and video tutorials. I’ve been watching “PowerShell 7 for Beginners” from JackedProgrammer, and I would even get a reference guide sooner or later. It can go proper subsequent to my 1996 paperback version of O’Reilly’s HTML: The Definitive Guide.
