Category Archives: PowerShell

PowerToys Team Closes WinGet Gap

Now THAT’s what I like to see. Yesterday morning, I noticed a new version of PowerToys (v0.71.0) was out. So quite naturally, I ran WinGet to upgrade same. No dice. At 11:45 AM (Central) I tweeted  about this. I observed it was “kind of surprising to see a new PowerToys release…without a matching WinGet upgrade manifest.”  8 minutes later, the team leader responded “we’re working on it.” And by that afternoon, the PowerToys team closes WinGet gap. There’s a working manifest for version 71 in place. Neat-o, and thanks, people!

PowerToys Team Closes WinGet Gap Quickly

It’s a real testment to the energy and drive of the teams involved that things were already in progress as I reported in. (In fact, I heard from the WinGet team lead, too.) This morning I installed PowerToys on the Lenovo ThinkPad X1 Extreme (8th-gen i9, 32 GB RAM, 1.5 TB SSD) and got the latest version. That sequence appears as the lead-in graphic above.

If you look at that graphic, you’ll see that WinGet found only a Zoom upgrade. Oops! That’s because PowerToys wasn’t installed on this PC — yet. But when I did install the .exe version (Microsoft. Powertoys) 0.71.0 (shown as v0.71.0 in the thumbnail at lower right) appears. That’s exactly what should have happened,. It also shows the WinGet manifest for that version of PowerToys is present and working properly.

Always Nice When Things Work Out…

I must say that both the WinGet and PowerToys teams have always been great to work with. They respond to input, questions, and feedback quickly. And when they have to act, they tend to do so sooner than later. Thus, my thanks to Demetrius Nelon (WinGet team lead) and his merry munchkins, as well as Clint Rutkas (PowerToys team lead) and his peppy people, too.  Please: keep up the good work.

 

Facebooklinkedin
Facebooklinkedin

Sussing Out WinTerm Color Schemes

In my writing and research work for TekkiGurus, I’m pursuing a GitHub project that works within the Windows Terminal environment. It’s called ColorTool. Simply put, ColorTool shows the colors used in the console window; it also lets you tweak them. Its color charts are kind of interesting and I’ve trying to figure them out. MS has a tendency to show them inside an Ubuntu command session inside Windows Terminal. I show them as they pop up in PowerShell in the lead-in graphic. As I’m learning how this all works, I’m sussing out WinTerm color schemes, too.

Bing Chatbot Helps When Sussing Out WinTerm Color Schemes

I’ve been reading a lot, and asking around to try to learn how to decode the values that show up in the display form of a Windows Terminal color scheme. So far, it’s proved rather more challenging than I had expected. So far, I’ve been attacking output strings to tease out their meanings. This is what I’ve learned so far, mostly thanks to the Bing Chatbot in Windows 11 Canary (Build 25393):

  • The string “gYw” that appears in the columns of rows 2-10) stands for gray, yellow and white. It uses prevailing foreground color, whatever that may be.
  • The values 30m through 37m that appear as row heads (first column left) are ANSI escape codes for foreground colors
  • The values 40m through 47m that appear as column heads (second column through 9th column left) are ANSI escape codes for background colors.
  • Looking at the color chart, the text strings “gYw” show the foreground color, while the solid bar for each column shows the background color.

In profound contrast, Ubuntu puts foreground colors as columns, and background colors as rows. I also shows escape sequences instead of color names. Initially, this bamboozled me. But now I see what’s going on…

Sussing Out WinTerm Color Schemes.ubuntu

Notice that background appears as double rows with escape codes at left in column 1, and foreground colors appear as the text for escape codes in rows 2-9).

Wow, it’s all starting to make a certain amount of sense. And I mostly have the Bing Chatbot to thank for explaining such extremely low-level details. Apparently, those who work with terminal/console color charts know all this stuff already.

Now, I finally understand that a color scheme assigns a range of color values to the 8 ANSI escape codes for the foreground colors 30m through 37m (which may also be expressed as ESC[30m …). It does the same for the 8 ANSI escape codes for the background colors, too (40m through 47m, likewise ESC[30m).

OK, Now I Know What’s What

Suddenly, I feel armed with the information I need to make sense of the Windows Terminal color schemes and their related color charts. This should make my jobs of explaining them, and their customization, a WHOLE LOT easier. I’m jazzed…

Facebooklinkedin
Facebooklinkedin

Testing Bing Chat AI Text Generation

Hmmm. This has been interesting… I’ve been using the Bing Chat tool in the Canary Channel version of Windows 11 lately. I just asked it to shed some light on a Windows Console (aka Windows Terminal) tool that I’ve been working with lately. Let me provide the query I used while testing Bing Chat AI text generation:

“Give me 400 words about the Winodws Console colortool”

I’ll provide the results as a blockquote under the next heading. Then I’ll explain what’s good about it and where — IMO at least — it falls a little short.

Results from Testing Bing Chat AI Text Generation

Notice that the chatbot correctly interprets my mistyping of Windows as “Winodws” in the input, and gives me the answer I wanted. Good stuff! Here’s what it told me:

The Windows Console Colortool is a utility that helps set the color palette of the Windows Console. It can be used to apply the new default color scheme and several alternate pre-defined color schemes or even schemes of your own1The tool is open source and hosted on GitHub2.

To use the Colortool, open up Command prompt and run: colortool [scheme name in schemes/ e.g: campbell]. Right-click on the window title to access the ‘Properties’ dialogue box. Once the properties dialogue box opens press OK (which saves the color change)1.

Notice it provides highlighted, hyperlinked text to additional references (which show up in the lead-in graphic as footnotes 1 and 2). It’s essentially a rewrite of descriptive information from the colortool’s github page. Curiously, that does not show up as the primary reference here (it’s number 2, though). Concerns about the accuracy of the material I’ve seen voiced in other analyses are apparently NOT an issue when you ask the chatbot to keep the text short. Everything it says it 100% accurate and verifiable.

OK Then, What’s Missing?

The text does not explain that the ZIP file for the colortool must be downloaded and unpacked into a folder that’s either included in the $PATH environment variable, or made the focus of the Command Prompt (or PowerShell) session in which the tool gets invoked. It just assumes all those details have been handled and jumps straight into the syntax and behavior of the tool itself.

That’s all well and good, but makes a telling demonstration of why AI chatbots can help, but not necessarily take over, for knowledgeable human actors with a more nuanced understanding of the context in which they’re operating. At least not yet, anyway…

It’s extremely interesting stuff, and is definitely going to help me with my job of explaining things to readers in the future. If you’re running the Canary Build (25393) for Windows 11, click the Bing symbol at the upper right of the default Edge window to dig in and try it for yourself. Great fun!

Facebooklinkedin
Facebooklinkedin

WinGet Chrome Update Follies Continue

There are many occasions when I run WinGet and it tells me Chrome needs an update. Sometimes, WinGet handles that update; other times it does not. I just pushed my luck, and got more information about why that happens. It’s shown in the lead-in graphic, and indicates a change in the “install technology” is involved. In such a start-stop fashion, my WinGet Chrome update follies continue…

Yes/No: WinGet Chrome Update Follies Continue

WinGet is inherently conservative by design. If the developers change something about the installer WinGet calls to handle updates, it won’t force that update. As you can see in the lead-in graphic, when I explicitly tell WinGet to update Chrome (e.g. winget upgrade google.chrome references the package name) it gives me an informative error message instead:

A newer version was found, but the install technology is different from the current version installed. Please uninstall the package and install the newer version.

OTOH, if I fire up Chrome, then click on Help → About, it’s happy to update itself at my behest. See?

WinGet Chrome Update Follies Continue.internal-update

The internal update facility in Chrome doesn’t care about “install technology.” It just runs.

The advice in the WinGet message thus really targets using WinGet to perform the upgrade. Indeed if you run this sequence of commands:

WinGet uninstall Google.Chrome

WinGet install Google.Chrome

then Winget will achieve the desired result of updating Chrome. In the past, I’ve speculated that if Chrome is running, the update might not happen. Now that I see this error message, this looks like a much more likely explanation.

But wait…!

I tried this on another test PC just now, and on that machine the Chrome update proceeded without any issue. Go figure!

Maybe it is a case of whether or not a Chrome process is running. On the other test PC it had just been rebooted, so no such potential complications were present. It’s always something, right?

Facebooklinkedin
Facebooklinkedin

MS Defender Update Targets Deployment Images

If you can trust the header data in this MS Support note (I do) it was updated on June 5, 2023. The item is entitled “Windows Defender update for Windows Operating system installation. It describes how to imbue offline Windows images with the latest and greatest Defender capabilities. In fact, that article includes a warning not to apply them to live images. Thus, it’s clear that this MS Defender update targets deployment images.

I got my date information about the article from its HTML meta-data:

<meta name="lastPublishedDate" content="2023-06-05">
<meta name="firstPublishedDate" content="2020-12-04">

How  MS Defender Update Targets Deployment Images

Pre-requisites to run the updates — for WIM and VHD files — include:

  • Works on OS install images for 64-bit Windows 10 and 11, and Windows Server 2016 and 2019
  • OS environment must include PowerShell version 5.1 or newer (current production version is 7.3.4 as I write this)
  • Microsoft.Powershell.Security and DISM modules installed
  • The PowerShell session for the script  <code>DefenderUpdateWinImage.ps1</code> runs with admin privileges. (“Run as administrator” or equivalent.)

The script provides switches to apply, remove or roll back, and list details for the installed update. Useful for those who maintain Windows images and want their security levels up to current snuff.

Find all the details in the MS Support article previously named. Do this before your next scheduled update window, for sure. Of course, this means you’re using Windows Defender as part of your security infrastructure.

MS Is BIG in Security

I just worked on a promotional piece for a joint Rubrik and MIcrosoft security webinar (YouTube video). Amazingly, MS describes itself as “the biggest cyber security company in the world” and did over US$20B in such business in 2022. I guess they do have some legs to stand on in this arena. And indeed, they’re doing all kinds of fascinating stuff with AI and ML to improve their security posture and incident response capabilities. Great stuff!

 

Facebooklinkedin
Facebooklinkedin

Deciphering PowerShell History Commands

Whoa! I just spent an enjoyable half-hour learning about the various PowerShell command line history viewing and editing tools. This comes courtesy of OhMyPosh creator Jan De Dobbeleer (@jandedobbeleer) on Twitter. Deciphering PowerShell history commands, in my case, involved a fair amount of interesting play and learning in a Terminal session. As you can see from the lead-in graphic, I had fun manipulating my command history (and then, updated OhMyPosh to catch up my test system).

When Deciphering PowerShell History Commands, Do This…

The operative way to understand PS history management is as a series of prefixes to “-history” at the command line — namely:

  • get: shows current PS command line history as stored for display
  • clear: clears current PS command line history
  • add: allows you to import a predefined command history from a file

There’s a lot more to managing history than you might think, as described in this MS Learn reference on the Clear-History command. Indeed you can tailor the history based on commands by number (from top or bottom of the history list, using -Count and other options) or by content (using the -CommandLine option and string-matching facilities).

Wait! There’s an Add-History, Too

You can save a representative command history by piping get-history into a CSV file. Later on, Add-History lets you import that file’s contents to imbue the current command history into your current PowerShell context. See this reference for more info.

Working with PowerShell history commands is great fun, actually. I’d suggest visiting the afore-linked references to take things for a spin. I find it useful to clear the history after such learning adventures (or after making mistakes at the command line that I’d just as soon forget…).

 

Facebooklinkedin
Facebooklinkedin

Another Interesting PowerShell Clean-up

Wow! What a ride… I was working on my Lenovo P16 Mobile Workstation this morning. Winget kept finding two versions of PowerShell — namely 7.3.8.0 and 7.3.4.0 — when I ran an open-ended upgrade command. That said, I couldn’t find the older version anywhere. Ultimately, this would lead me to another interesting PowerShell cleanup. Let me walk you through what I had to do to come clean, as ’twere…

Starting Another Interesting PowerShell Clean-up

I’ll begin by explaining where I started from. I was running the Preview version of PowerShell. The complete name string (FQDN equivalent): Microsoft.Powershell.Preview. The list command for that string was showing two versions in winget output, as described above. Upgrade attempts had no effect on the older version, despite reporting success. Sigh…

Also, when I searched all the folders where the software should be lurking (from the PowerShell environment variable), I found it nowhere. Likewise, my usual fallback trick — searching for filename pwsh.exe (the PowerShell executable) — showed only one instance.

Frustrating!

Ending the Clean-up Conclusively

When all else fails, remove/replace still does the trick. I ran the following commands to fix things so that only one version shows as in the lead-in graphic for this story:

1. winget uninstall -q Microsoft.PowerShell.Preview -v 7.3.8.0
2. winget uninstall -q Microsoft.PowerShell.Preview -v 7.4.0.3
2. winget install –id Microsoft.Powershell –source winget

That replaced the Preview with the Production version, and did away with the elusive (unfindable, even) older Preview version. Problem solved. Sheesh!

Note: Here’s a handy article from MS Learn “Installing PowerShell on Windows” that supplied me with number 3 above. Works well, but I did have to close my open PowerShell window for the install process to complete. Can’t have the old stepping on the new again, can we? Sigh again…

Facebooklinkedin
Facebooklinkedin

Windows 10 Dual Progress Bars Mystery

Back in November 2017, I posted the item shown in the lead-in graphic to Windows TenForums.com. I get two progress bars when running DISM ... /StartComponentCleanup on my Windows 10 PCs. The thread is interesting to read, and offers a good explanation in item#4 for what’s happening: a spurious line feed somewhere in the DISM routines that handle this task. Just this morning, I noticed that this Windows 10 dual progress bars mystery persists to this day. But I’ve figured out more…

More Data for Windows 10 Dual Progress Bars Mystery

This doesn’t happen every time I run DISM ... /StartComponentCleanup on my Windows 10 PCs. It happens only if I’ve just applied a Cumulative Update to that machine, and I haven’t rebooted the machine a second time after the post-update reboot. And, in fact, I just replicated this very same issue on one of my Windows 11 22H2 PCs as well in those same circumstances.

I’m still wondering about why this happens. I take it as ongoing proof that problems do make themselves visible in Windows (10 and 11) occasionally. Ditto for the observation that some glitches are more important than others.

This particular glitch, while interesting, is benign. It’s just a hiccup in the DISM output. Everything works as it’s supposed to, except for the dual progress bars (or appearance thereof if my TenForums informant is correct about the “spurious linefeed” theory). But here is the error in Windows 11 as well. Note: the build number shown, 22621, identifies this OS as Windows 11 22H2 even though the “Major” OS version reads “10.”

Windows 10 Dual Progress Bars Mystery.Win11I love a good mystery. I hope someday to see this fixed, though…

Facebooklinkedin
Facebooklinkedin

Winget Discord Update Trick

I’ve got a new PC waiting in the wings to take over for my aging production PC. Right now, it’s ensconced in my son’s bedroom, where I use it as a test machine. He also games on it when he comes around. As a Discord user, he checks in on that app daily when he’s here. One of his tools pinned that app, so Winget can’t upgrade it through normal means (e.g. Winget upgrade –all or some equivalent). But I’ve discovered a Winget Discord update trick that works nonetheless.

Pinning Requires Winget Discord Update Trick

For some time now (as described in this July 2020 GitHub thread) users and programs can “pin” packages for Winget. This explicitly holds Discord to some specific version (or range of version numbers). It also means that unless Winget upgrade is targeted with a specific Discord version, it doesn’t perform the upgrade.

The trick to a successful upgrade is to use the –version parameter with Winget upgrade to explicitly specify the upgrade target. For example, I successfully upgraded the upstairs PC with this command:

winget upgrade Discord.Discord –version 1.0.9012

Note: I had to use the “full package name” for the Discord app (“Discord.Discord”). I also had to provide the complete version number (1.0.9012) following the –version parameter. After jumping through those hoops, the pinned version allowed the update. One presumes that the same approach will work for other pinned apps and applications with Winget as well.

It may take some squinting, but you can see Discord’s version info in the lead-in graphic at the far right. It reads “Host 1.0.9012 (30921).” To the left is a Terminal window that shows a successful targeted upgrade (update, actually) of the Discord app itself. It’s easy — if you know how. Those are the deets! And now, it’s all good…

Facebooklinkedin
Facebooklinkedin

Strange wt.exe Windows Terminal Behavior

I’ve got to admit I love nothing better than a good Windows mystery. And right now: I seem to have a doozy on my hands. Here’s the deal: if I open Windows Terminal on my production Windows 10 PC, it won’t run another terminal instance (wt.exe) either in PowerShell or in a Command Prompt pane. You can see this in the lead-in graphic above. The PowerShell error message also provides profound guidance on what’s going on here with this strange wt.exe Windows Terminal behavior. Can you see it, too?

Why Get Strange wt.exe Windows Terminal Behavior?

The clue is in the error message text where it shows the path for the version of wt.exe that PowerShell or Command Prompt tries to run. It’s the Preview version, which I have installed alongside the production version on this — and only this — PC here at Chez Tittel. By no coincidence, it’s also the only machine here that’s having this problem.

That said: I’ve also found various workarounds that bypass this issue:

1. Providing the complete path spec for the non-preview version launches a new Terminal window from  Command Prompt. The complete path spec for the preview version still provokes “access denied.” It sits there and does nothing inside PowerShell.
2. Opening Voidtools Search Everything, right-clicking and selecting “Run as administrator” launches a new Terminal window for either version. The same approach works in File Explorer, too. Ditto for Start menu access (but only for the production version, which is the only one that has a Start menu entry).

Version Confusion Path Dynamics

To me, this problem seems obviously path related. And indeed, the first entry in the PATH variable on the affected PC reads:

C:\Program Files\WindowsApps\Microsoft.WindowsTerminalPreview_
1.17.10234.0_x64__8wekyb3d8bbwe;

That explains why the shell tries to run the Preview version in the first place when it’s called at the command line. It’s very likely a side-effect of the Terminal Preview installation process. I didn’t edit PATH to include it, that’s for sure.

And it turns out that when wt.exe runs, it adds itself to the PATH. This raises the question of why, even when I launch the production version, the Preview is the version added to the PATH. Interesting!

Workarounds Will Cover My Needs

For the time being I can get Terminal to do what I need it to do without completely figuring out this strange path dynamic that’s at work. I imagine that I could simply uninstall the Preview version and my issue would disappear. I’ll think about and fool around with this for a while yet, and see if I can figure another solution. For further discussion of what turns out to be a bigger mystery than I was expecting see this github issues thread: Windows terminal path is different if launched with wt.exe. This one appears to possess Dantean qualities (“Abandon all hope, ye who enter here…).

Let me be clear about this, though. This happens only on one of my near-dozen Windows PCs. And it’s the only one with both Preview and Production versions of Windows Terminal running side-by-side. It’s definitely a tempest of sorts, but one in a pretty small teapot.

Facebooklinkedin
Facebooklinkedin