Friday, March 9, 2018

cipher /adduser says "access denied" if the files are read-only

Today I needed to allow a new user to access some EFS-encrypted files. Despite my account having an appropriate certificate and full access to the files, cipher /adduser said "access is denied" for each of them and couldn't add the user. Confusingly, performing the operation on new encrypted files worked perfectly fine. Eventually I ran some other mode of cipher, which gave a more helpful message indicating that the files were read-only. Apparently EFS won't allow certificate list changes if the read-only bit is set. Unmarking them read-only made things work as expected.

Wednesday, March 7, 2018

Policy Plus - Considering how to improve the ADMX loader

Today I did some experiments with the official Local Group Policy Editor to determine how Policy Plus should respond to problems with the ADMX complement. The LGPE rejects an ADMX as soon as it sees a duplicate ADMX namespace, while Policy Plus currently waits to fail until a policy object is duplicated. I think that's OK even though it might lead to some strange behavior; being more forgiving than the LGPE can't hurt as long as there's a warning that something bizarre might be going on. Policy Plus should definitely not fail the entire workspace's load when it hits this problem, though.

When it comes to missing ADML files, the LGPE fails the load of the corresponding ADMX. (Again, Policy Plus currently fails the entire workspace.) I think ignoring that one ADMX is reasonable; trying to continue using the display codes as the text would work for simple policies, but without the ADML, there's no way to arrange the presentations of extra options.

Tuesday, March 6, 2018

PowerShell assignment can unpack arrays into variables

I was surprised to learn a few days ago that PowerShell can assign multiple variables in one expression:

$a, $b = 1, 2

As expected, that puts 1 into $a and 2 into $b. It turns out such syntax works with nonliteral arrays on the right:

$numbers = @(1, 2)
$a, $b = $numbers

Having more variables on the left than there are elements in the array assigns null to the extra variables.

Monday, March 5, 2018

Intel wireless driver updates aren't delivered through Windows Update

For a while, I had wondered why my laptop's WiFi struggled to make any connections for a while after the machine resumed from sleep. Today I finally decided to check for a driver update. Nothing was available through Windows Update or the Update Driver feature of Device Manager. Googling the name of the Intel wireless device, however, brought up the downloads page, which had a new major version of the driver. Apparently it's entirely possible for there to be Intel driver updates without any notice through the Windows integrated delivery mechanisms.

Sunday, March 4, 2018

mklink needs the directory name available, not just an empty directory

One user was having some trouble with using mklink to redirect a folder to another drive. They had (seemingly) deleted its contents, but mklink still refused to make a link, saying that the filename was already taken. This is because mklink doesn't transform existing folders into junctions or symbolic links; it creates a new item with the given name. Deleting the existing folder should allow the creation of a new junction/link with that name.

Saturday, March 3, 2018

Any sequence of numbers can index a PowerShell array

It's moderately common to take a "slice" of PowerShell arrays by using a range inside the brackets, like $arr[0..3] to get a sequence of the first four elements. The .. syntax isn't special-cased in array indexing; you can use any expression that generates a series of numbers. Even pipelines are fine. If it's complicated, you might have to enclose the whole thing in parentheses. To get all the array elements at even indexes, you could do this:

$arr[(0..($arr.Length - 1) | ? { $_ % 2 -eq 0 })]

Assign 2 GB of RAM to Hyper-V machines before trying to upgrade Windows 10

Hyper-V has a dynamic memory feature that allows it to change how much RAM is allocated to the virtual machine while it's running. The absolute minimum - usually much less than will be allocated for realistic workloads - is set in the VM configuration. When starting the upgrade to a new build of Windows 10, the setup infrastructure checks whether the machine has at least 2 GB of RAM. If the check fails, it cancels the upgrade and deletes the update files. To avoid needing to wait for the update to be downloaded again, I'd advise making sure the VM is guaranteed 2 GB before trying to start the upgrade.