I have 2500 machines and out of these 47 have an issue caused my scavenging after windows update - Microsofts suggested fix is upgrade using media - this isn't really feasible and I actually don't think it will work, I've found a solution to reinject the previously scavenged files so the 22H2 enablement pack will complete. I'm currently trying to script the fix so it can be pushed out with MEMCM. I've tried every command I can to sort out the output of get-childitem
$Key = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\"
$Keys = Get-ChildItem -Path $Key -Recurse | Where {$_.Name -Like "*Microsoft-Windows-*Enablement*" -OR $_.Name -Like "*KB4562830*"}
The output of this is messy (I would prefer each result to be on a new line) but what I get is ...
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-20H2Enablement-Package~31bf3856ad364e35~amd64~~10.0.19041.47
9 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-20H2Enablement-Package~31bf3856ad364e35~amd64~~10.0.19041.
479\Owners
with each line just continuing on.
So I tried to reformat into a new variable to be used with get-acl but this does only the first line correct and has a proceeding space on every subsequent
$KeysACLs = Foreach ($KeysACL in $Keys){
("Registry::" + ($KeysACL).Name)| out-string
}
Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-20H2Enablement-Package~31bf3856ad364e35~amd64~~10.
0.19041.479
Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Microsoft-Windows-20H2Enablement-Package~31bf3856ad364e35~amd64~~10
.0.19041.479\Owners
I'm by no means a coder in any way but any light you can shed on this would be greatly appreciated - or a completely different approach, this is what is needed to fix the issue ....
search the above key for the 2 names - usually brings back 10 or so results - I then need to take ownership of the keys, run a DISM command to fix the issue - this will re-write parts of the key, then change ownership back and then run the 22H2 enablement pack and SSU.
Cheers