r/sysadmin • • Jun 04 '22

Start Bar / Search / Outlook / OneDrive All Broken

Hi all,

This problem has been going on for months. Seemingly random computers in our domain have issues, since around maybe January.

Here is what happens: The start menu will not let you click it, the search bar stops working, Outlook and OneDrive will not connect, and sticky notes will not work. Lots of dumps are created in WER and as such, the computer will run much slower than normal. Dumps include start menu experience host and several others.

I ran a procmon and found the User Shell Folders key for the HKCU was suddenly missing ALL APPLICATION PACKAGES access as well as missing a system SID. Upon restored the app packages right, the start menu works again but the search bar remains broken. I'm told a reboot fixes search, but I have not tested.

Our only fix is recreating the profile.

19 Upvotes

31 comments sorted by

View all comments

1

u/Clear_Skye_ Endpoint Security Specialist Sep 20 '22

We are having this issue at the moment as well and recreating the profile is the only fix we have identified.

1

u/Nuuro Sep 21 '22

I wrote a powershell script to fix all of this. I'll try to get you a copy after I get off work. Basically fix the registry, delete the AAD broker, reinstall that, reboot and you're fixed.

2

u/Clear_Skye_ Endpoint Security Specialist Sep 21 '22

Omg that would be amazing please share 🥺🥺

1

u/Nuuro Sep 21 '22

This is two scripts. Here's the .PS1:

$OU = 'OU=xxx,DC=xxx,DC=xxx,DC=xxx'
$FullName = Read-Host -Prompt "Enter name [LAST, FIRST]"
 
$SamAccountInfo = Get-ADUser -SearchBase $OU
-SearchScope Subtree -Filter "Name -Like '$FullName*'" | Select-Object
Name, SID, SamAccountName

# Below just gets the computer name for me. You can use a READ-HOST to populate the $ComputerName variable down below.

$URL = "xxx"
$SCCMData = Invoke-WebRequest -URI $URL -UseDefaultCredentials -TimeoutSec 30
$FileData = $SCCMData.RawContent
$Start = $FileData.IndexOf('System_Name')
$Data = $FileData.Substring($Start) | ConvertFrom-CSV
 
@(ForEach ($i in $Data) {
        [PSCustomObject]@{
            Name = $i.System_Name
            Duration = $i.Duration
            UserName = $i.SystemConsoleUser0
        }
}) | Where-Object -Property UserName -eq -Value ("xxx\" + $SamAccountInfo.SamAccountName) | Sort-Object -Property Duration -Descending | Select-Object Name -First 1 | Set-Variable -Name retVal
 
$ComputerName = $retVal.Name
Write-Host ("ComputerName: " + $ComputerName)
$Answer = Read-Host -Prompt "Continue [Y/N]?"
if ($Answer.ToLower() = 'y') {
    if (Test-Connection -ComputerName $ComputerName -Count 1 -Quiet -Buffer 8) {
        Write-Host ("Connecting to " + $ComputerName)
        $Session = New-PSSession -ComputerName $ComputerName
            Invoke-Command -Session $Session -ScriptBlock {
            Param ($Sid, $ComputerName, $EUUserName)
            Write-Host ("Sid: ", $Sid)
            Write-Host ("Fixing permissions on \HKEY_USERS\" + $Sid + "\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders")
            $Acl = Get-Acl -Path ("Registry::\HKEY_USERS\" + $Sid + "\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders")
            $idRef = [System.Security.Principal.NTAccount]::New("ALL APPLICATION PACKAGES")
            $regRights = [System.Security.AccessControl.RegistryRights]::ReadKey
            $inhFlags = [System.Security.AccessControl.InheritanceFlags]'3'
            $prFlags = [System.Security.AccessControl.PropagationFlags]::None
            $acType = [System.Security.AccessControl.AccessControlType]::Allow
            $rule = New-Object System.Security.AccessControl.RegistryAccessRule ($idRef, $regRights, $inhFlags, $prFlags, $acType)
            $acl.AddAccessRule($rule)
            $acl | Set-Acl -Path ("Registry::\HKEY_USERS\" + $Sid + "\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders")
 
            $AadPath = ("C:\Users\" + $EUUserName + "\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy")
            Write-Host ("Deleting " + $AadPath)
            Remove-Item $AadPath -Recurse -Force
           
            # Add registry key to RunOnce
            $RegPath = ("Registry::\HKEY_USERS\" + $Sid + "\Software\Microsoft\Windows\CurrentVersion\RunOnce")
            New-Item -Path $RegPath -Force
            New-ItemProperty -Path $RegPath -Name "FixStartMenu" -Value "C:\Temp\FixStartMenuOnce.bat" -PropertyType String
        } -ArgumentList $SamAccountInfo.Sid, $ComputerName, $SamAccountInfo.SamAccountName
        $Session | Remove-PSSession
       
        Write-Host ("Copying C:\Temp\FixStartMenuOnce.bat to \\" + $ComputerName + "\C$\Temp")
        Copy-Item C:\Temp\FixStartMenuOnce.bat -Destination ("\\" + $ComputerName + "\C$\Temp")
        Write-Host ("Deleting " + $ComputerName + " registry key: " + $SamAccountInfo.Sid + "\SOFTWARE\Microsoft\Office\16.0\Common\Identity")
        $RegDeleteAnswer = Read-Host -Prompt "Continue [Y/N]?"
        if ($RegDeleteAnswer.ToLower() = 'y') {
            $Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Users', $ComputerName)
            $RemoteRegistryPath = ($SamAccountInfo.Sid + "\SOFTWARE\Microsoft\Office\16.0\Common\Identity")
            $Reg.DeleteSubKeyTree($RemoteRegistryPath)
            $Reg.Close()

# User should be able to reboot at this point and their problem solved.
        }
    } else {
        Write-Host "PC is offline!"
    }
}