Regarding GPO and PowerShell

SHUO .H 706 Reputation points
2020-07-28T07:09:24.433+00:00

hi there,

I setup the GPO to change the Client's registry like the shown below:

# ($_OneDrive = Get-Item -path HKLM:\Software\Policies\Microsoft\OneDrive -ErrorAction SilentlyContinue) -eq $null
if((Test-Path "HKLM:\Software\Policies\Microsoft\OneDrive" -ErrorAction SilentlyContinue) -eq $true)
{
    Write-Host $_OneDrive

    New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT

    if((Test-Path "HKCR:\CLSID\{04271989-C4D2-689D-E58A-84C94193AFF6}" -ErrorAction SilentlyContinue) -eq $true)
    {
        Set-ItemProperty -Path "HKCR:\CLSID\{04271989-C4D2-689D-E58A-84C94193AFF6}" -Name ‘(Default)’ -Value "doclib (unclassified)"
    }     

    # if ((Get-ItemProperty “HKLM:\Software\Policies\Microsoft\TESTING” -Name “r1” -ErrorAction SilentlyContinue) -ne $null){
    #      Set-ItemProperty “HKLM:\Software\Policies\Microsoft\TESTING” -Name “r1” -Value "2020"
    # }

    # if(($_CLSID = Get-Item -path 'HKCR\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}'))
    # {
    #     Write-Host $_CLSID
    # }    
}
else
{ 
    # Set the location to the registry
    Set-Location -Path "HKLM:\Software\Policies\Microsoft"

    # Create a new Key

    Get-Item -Path "HKLM:\Software\Policies\Microsoft" | New-Item -Name "OneDrive" -Force

    # Create new items with values
    New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\OneDrive" -Name "SharePointOnPremFrontDoorUrl" -Value "http://win-i1ns5qsofnv:31018" -PropertyType "String" -Force
    New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\OneDrive" -Name "SharePointOnPremPrioritization" -Value 1 -PropertyType "DWord" -Force
    New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\OneDrive" -Name "SharePointOnPremTenantName" -Value "Contoso" -PropertyType "String" -Force

    # Get out of the Registry
    Pop-Location
}

this part: always cannot modify the client's registry. does anyone have any idea on it?? Thanks

 if((Test-Path "HKCR:\CLSID\{04271989-C4D2-689D-E58A-84C94193AFF6}" -ErrorAction SilentlyContinue) -eq $true)
        {
            Set-ItemProperty -Path "HKCR:\CLSID\{04271989-C4D2-689D-E58A-84C94193AFF6}" -Name ‘(Default)’ -Value "doclib (unclassified)"
        }     
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,724 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,355 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. 2020-07-30T02:01:07.65+00:00

    Greeting SHUOH-8693,
    First of all, in order to narrow the scope of inspection, we need to clarify whether this problem is a GPO problem or a PS problem.
    Therefore, if you manually change the user registry, can this operation be successful?
    If it is not successful, it may be due to lack of permissions or setting errors.
    If it succeeds, it is the cause of the PS. We can check the error report to solve the problem.
    Looking forward to your reply.
    Best wishes,
    Young Yang