Replies: 1 comment
-
|
For already-loaded users, this is just So I would not model this as one recursive
Pseudo-flow: Get-CimInstance Win32_UserProfile |
Where-Object { -not $_.Special -and $_.LocalPath -and (Test-Path "$($_.LocalPath)\NTUSER.DAT") } |
ForEach-Object {
$sid = $_.SID
$loadedPath = "Registry::HKEY_USERS\$sid"
$tempName = "DSC_$($sid -replace '[^A-Za-z0-9]', '_')"
$root = $loadedPath
$loadedByScript = $false
if (-not (Test-Path $loadedPath)) {
reg.exe load "HKU\$tempName" "$($_.LocalPath)\NTUSER.DAT" | Out-Null
$root = "Registry::HKEY_USERS\$tempName"
$loadedByScript = $true
}
try {
New-Item -Path "$root\Software\Policies\Vendor\Product" -Force | Out-Null
New-ItemProperty -Path "$root\Software\Policies\Vendor\Product" -Name SomeValue -Value 1 -PropertyType DWord -Force | Out-Null
}
finally {
if ($loadedByScript) {
[gc]::Collect()
reg.exe unload "HKU\$tempName" | Out-Null
}
}
}If you want this to stay in a DSCv3 design, I would wrap that enumeration/load/unload logic in a script/custom resource and keep Also, if the setting has an Intune Settings Catalog / ADMX-backed equivalent, prefer that. Directly writing old user-policy keys is useful for migration gaps, but you are then responsible for targeting, removal, and deprovisioning behavior that Group Policy previously handled. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
DSCv3 Microsoft.Windows/Registry ressource works very well to configure registry keys in :
HKLMwhen DSCv3 is executed with a system accountHKCUwhen DSCv3 is executed with logged in user permissions.However, how could we recursively apply a USER policy setting (ie: registry key), formelly applied by a USER Group Policy setting, to all user profiles listed in
HKUwithout waiting for all users to log in ?Use case is to use DSCv3 as a detection/remediation script in Intune to fill the gap between Intune and group Policies and migrate all registry USER Group Policy settings to Intune. Intune package provided in https://www.cyber.mil/stigs/gpo/ uses a DSCv2 (powershell) package to do this. We would like to to it with DSCv3
Beta Was this translation helpful? Give feedback.
All reactions