Closed ghost closed 8 years ago
You are right, for some strange reason adding the -Force
flag to mkdir
will remove all subsequent registry keys. But this does not happen outside the registry.
Like I said I'm new to Powershell but I think this might work:
function createFullPath($path) {
if (!(Test-Path $path)) {
Write-Host "-- Creating full path to: " $path -ForegroundColor White -BackgroundColor DarkGreen
New-Item -ItemType Directory -Force -Path $path
}
}
createFullPath("HKCU:\SOFTWARE\Microsoft\Input\TIPC")
It's really dangerous to keep the force flag, I noticed the script removed some other folders that were present, for example, inside "HKCU:\SOFTWARE\Microsoft\Input\TIPC".
By the way feel free to use the code I mentioned before, I think it's something MS implemented on the AU. I was getting suggested apps installed even on Enterprise. That's the only way I was able to stop it.
Anyway, thanks for the awesome script!
Another suggestion: maybe we could do some kind of executable test suite that shows if any of the configs changed on an update. Maybe a startup script that only shows output if any test failed.
Proof of concept:
function runTest() {
param ($name, $value, $expected)
Write-Host 'Test:' $name
if ($value -eq $expected) {
Write-Host 'SUCCESS' -ForegroundColor White -BackgroundColor DarkGreen
} else {
Write-Host 'FAIL' -ForegroundColor White -BackgroundColor Red
Write-Host 'Value:' $value -ForegroundColor White -BackgroundColor Red
Write-Host 'Expected:' $expected -ForegroundColor White -BackgroundColor Red
}
}
# run tests
$v = (Get-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\datacollection).allowtelemetry
runTest -name 'Allow telemetry' -value $v -expected 0
I noticed your script is using the -Force flag on mkdir. I don't know Powershell enough but isn't that flag too destructive?
I was trying to add the new keys for ContentDeliveryManager and for some reason if I add that force flag it deletes all the subfolders of the target. I end it up using:
Am I wrong?