Closed Raphire closed 2 months ago
After testing this I have been able to determine the script does apply the registry changes correctly to the default user profile. It seems however that these changes are not copied over to new users. I have been looking for alternative ways to apply these changes, but no luck so far.
@Raphire, this might not fix your problem because you did say the change took effect properly, but you might try doing garbage collection first before closing the default registry hive. This is how I've done it in the past to ensure the hive takes effect properly. I had to do this during an Autopilot process or even though the registry got the change on the default hive the user that logged in wouldn't get the changed value.
# $ITErrorCodes is a hashtable with keys with the friendly names of status codes and values for their errorcode number. These lines can be omitted in your use case, this is just how my code worked.
$unloaded = $false
$attempts = 0
$exitCode = $ITErrorCodes.Success
while ((-not $unloaded) -and ($attempts -le 10)) {
$attempts += 1
Write-Host "Unloading the default user registry hive. Attempt $attempts."
[gc]::Collect()
Start-Sleep -Seconds 5
& reg.exe unload "$ITDefaultUserHiveLoad"
$unloaded = $?
}
if (-not $unloaded) {
Write-Warning "Unable to dismount default user registry hive at $ITDefaultUserHiveLoad. Manual dismount required"
Write-Warning "Setting exit code to $($ITErrorCodes.SuccessRebootRequired) SuccessRebootRequired"
$exitCode = $ITErrorCodes.SuccessRebootRequired
}
Here's a better explanation. Apparently you're also supposed to close open handles before doing the garbage collection.
https://dansonnenburg.wordpress.com/2022/03/22/setting-value-in-the-default-user-registry-hive/
@sean-sauve Thanks for the additional info and an example of your implementation. I am planning on reworking the way the script applies registry edits to also tackle #72.
I think it's the same I read on the forum at the end of https://ccmexec.com/2021/10/modifying-windows-11-start-button-location-and-taskbar-icons-during-osd-autopilot/ and I reported on thread #104
With 6b7c4db the following options now work in Sysprep mode:
Please note that these changes are applied to the user account after the OOBE, this means that they will have to sign-out and back in before the changes are visible.
Describe the bug Some options don't apply to any accounts if the script is run in Sysprep mode within the Windows Audit Mode environment.
To Reproduce Steps to reproduce the behavior:
Expected behavior The above mentioned options should apply to the account after going through OOBE