Len Kally
asked on
How can I add items in the registry via powershell?
I want to change a setting in the local GP of a bunch of machines: Computer Configuration > Administrative Templates > Control Panel > Regional and Language Options > Block clean-up of unused language packs.
It is in the local Group policy but it is not in the registry.
It is NOT in the registry on a Windows 10 v1809 Enterprise Edition . In the registry it only shows: HKLM\Software\Policies\Mic rosoft. After that there is no Control Panel\International
Can I add this manually in the registry:
Key: HKLM\Software\Policies\Mic rosoft\Con trol Panel\International
Value: blockCleanupOfUnusedPreins talledLang packs
Enable: 1
This machine is not part of a domain. It is in a work group.
If I can does anyone know how to do it via PowerShell Script?
thanks
It is in the local Group policy but it is not in the registry.
It is NOT in the registry on a Windows 10 v1809 Enterprise Edition . In the registry it only shows: HKLM\Software\Policies\Mic
Can I add this manually in the registry:
Key: HKLM\Software\Policies\Mic
Value: blockCleanupOfUnusedPreins
Enable: 1
This machine is not part of a domain. It is in a work group.
If I can does anyone know how to do it via PowerShell Script?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The registry key is "HKLM:\Software\Policies\M icrosoft\C ontrol Panel\International", the value name is BlockCleanupOfUnusedPreins talledLang Packs, the type is REG_DWORD, the value is 1.
This is exactly what the script will do.
Block clean-up of unused language packs
https://getadmx.com/?Category=Windows_10_2016&Policy=Microsoft.Policies.Globalization::BlockCleanupOfUnusedPreinstalledLangPacks
Another possibility that works both in Batch and PS is reg.exe:
This is exactly what the script will do.
Block clean-up of unused language packs
https://getadmx.com/?Category=Windows_10_2016&Policy=Microsoft.Policies.Globalization::BlockCleanupOfUnusedPreinstalledLangPacks
Another possibility that works both in Batch and PS is reg.exe:
reg.exe add "HKLM\Software\Policies\Microsoft\Control Panel\International" /v BlockCleanupOfUnusedPreinstalledLangPacks /t REG_DWORD /d 1 /f
ASKER
I tried it and it worked added necessary setting to the registry but it did not change the Local Group policy settings. I ran gpupdate
Because the group policy has its own database where it stores its settings. The GP Editor does not read its settings from the registry.
When you enable the policy in the GP Editor, it will write to the registry, but that's a one-way street.
When you enable the policy in the GP Editor, it will write to the registry, but that's a one-way street.
ASKER
I thought Administrative templates are registry settings? And you can change the local group policy via a registry setting.
When I research on controlling the LGPO, it says find it's associated registry setting. Then there is no way to change this LGPO
Thanks
When I research on controlling the LGPO, it says find it's associated registry setting. Then there is no way to change this LGPO
Thanks
The local group policy processing will write the settings it finds in its database to the registry, where the respective components that use these policies will read them.
That is all.
You can not change the local GPO's database by writing to the registry.
If the (manually created) registry setting is there, it will work exactly the same was as if it would have been set by a GPO.
That is all.
You can not change the local GPO's database by writing to the registry.
If the (manually created) registry setting is there, it will work exactly the same was as if it would have been set by a GPO.
ASKER
wow thanks you been a real help, this is awesome
To "teach" you even more: you shouldn't need to write to the registry. Use GPOs and this gets set and gets set repeatedly (in case someone managed to delete that value). You give confusing info about GPO usage, since 1st you write
"It is in the local Group policy"
then you write
"It is not enabled in group policy"
as if you see that you can configure it, but simply don't do it. Why is that?
Use the domain policy to configure this and not scripts.
"It is in the local Group policy"
then you write
"It is not enabled in group policy"
as if you see that you can configure it, but simply don't do it. Why is that?
Use the domain policy to configure this and not scripts.
@McKnife,
He can't use a domain policy:
He can't use a domain policy:
This machine is not part of a domain. It is in a work group.
Then I missed that important part, sorry.
ASKER
Let me clarify, in the local GP on the machine I am testing: Computer Configuration > Administrative Templates > Control Panel > Regional and Language Options > Block clean-up of unused language packs
You either enable it or disable it.
When I go to the registry of that machine it only shows part of the LGPO:
In the registry it only shows: HKLM\Software\Policies\Microsoft. After that there is no Control Panel\International
I am asking since Administrative Templates are basically Registry setting, why isn't this LGPO not in the registry.
This is what I looked at, and why does the registry have International & the LPGO does not
https://www.exitcodezero.ch/2018/08/16/gpo-block-clean-upofunusedlp/
You either enable it or disable it.
When I go to the registry of that machine it only shows part of the LGPO:
In the registry it only shows: HKLM\Software\Policies\Microsoft. After that there is no Control Panel\International
I am asking since Administrative Templates are basically Registry setting, why isn't this LGPO not in the registry.
This is what I looked at, and why does the registry have International & the LPGO does not
https://www.exitcodezero.ch/2018/08/16/gpo-block-clean-upofunusedlp/
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Please keep your terminology straight.
If you disable the policy, the key will still show up in the registry, and the value for BlockCleanupOfUnusedPreins talledLang Packs will be 0.
The key will only disappear if you set the policy to "Not configured".
This is a big difference.
And for the third time: the group policy has its own database (C:\Windows\System32\Group Policy\Mac hine\Regis try.pol).
The GP processing that takes place based on the .pol file will only make sure that the registry keys defined in said file will be set.
But when you open the GP Editor, it does not care which keys do exist or not exist in the registry. It will only show you what's configured in its own database.
A manual change in the registry will never be reflected in the GP Editor, full stop.
If you disable the policy, the key will still show up in the registry, and the value for BlockCleanupOfUnusedPreins
The key will only disappear if you set the policy to "Not configured".
This is a big difference.
And for the third time: the group policy has its own database (C:\Windows\System32\Group
The GP processing that takes place based on the .pol file will only make sure that the registry keys defined in said file will be set.
But when you open the GP Editor, it does not care which keys do exist or not exist in the registry. It will only show you what's configured in its own database.
A manual change in the registry will never be reflected in the GP Editor, full stop.
ASKER
That is what is confusing to me, the registry setting only is: HKLM:\Software\Policies\Microsoft and I want to enable this policy. Will your script to this from what I see, it should under 'New-Item.
Thanks