安卓安装shadowrocket

Over the past couple of years since I last added a new post to this blog I’ve been halfheartedly working on converting from WordPress to one of the modern static generators but luckily a recent involuntary, but somewhat welcome, change in employment has freed me up to finally (hopefully) make some progress on that front. With any luck I’ll have the site updated to new hosting and back-end by the end of the year. I’ll be trying to document that process at least in the code repos, and possibly with a few posts here as well.

Update: It looks like I’ll be able to do one of the important settings in Terraform finally very soon.

No tag for this post.
Posted on Categories General

安卓安装shadowrocket

One of the lesser known features of PowerShell are some “magic” methods that get added to most (all?) collection objects that replace the slower Where-Object and ForEach-Object cmdlets with basically the same functionality. They’re considered magic because they aren’t well documented even years after they were introduced. (Thank goodness for bloggers) I’ve used ForEach quite a bit, but often forget about it’s Where counterpart and apparently had never actually done much with it until today when I ran into a weird issue where I couldn’t set the value of a property on a returned object.

The setup is a pretty classic needle-in-a-haystack problem where you have an array of objects and need to update a property on just one of them. Pretty classically you’d do something like this.

It works great but if you’ve got a really big array of complex objects it can start to take a long time to process. So today I had remembered the aforementioned magic methods and figured it would be a lot faster to use Where to do essentially the same thing. Except I got a really unexpected error.

Maybe it was returning a single element array? Running “$testElement -is [array]” said “False” but “$testElement[0].attr = ‘something'” worked just fine, so what was going on here? Time for some more “magic” in the form of the pstypenames property.

Of course while I was tinkering with all of that and doing some research on the Where and ForEach methods I ran across that article I linked further up and figured out the correct solution to the problem.