diff --git a/src/playbook/Executables/STARTMENU.ps1 b/src/playbook/Executables/STARTMENU.ps1 index 6a3e56382a..08e9b41aeb 100644 --- a/src/playbook/Executables/STARTMENU.ps1 +++ b/src/playbook/Executables/STARTMENU.ps1 @@ -8,11 +8,11 @@ foreach ($userKey in (Get-RegUserPaths).PsPath) { $appData = if ($default) { Get-UserPath -Folder 'F1B32785-6FBA-4FCF-9D55-7B8E7F157091' } else { - Get-ItemPropertyValue "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" -Name 'Local AppData' -EA 0 + (Get-ItemProperty "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" -Name 'Local AppData' -EA 0).'Local AppData' } Write-Title "Configuring Start Menu for '$sid'..." - if (!(Test-Path $appData)) { + if ([string]::IsNullOrEmpty($appData) -or !(Test-Path $appData)) { Write-Error "Couldn't find AppData value for $sid!" } else { Write-Output "Copying default layout XML" @@ -31,10 +31,12 @@ foreach ($userKey in (Get-RegUserPaths).PsPath) { } } - Write-Output "Clearing default 'tilegrid'" - $tilegrid = Get-ChildItem -Path "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount" -Recurse | Where-Object { $_.Name -match "start.tilegrid" } - foreach ($key in $tilegrid) { - Remove-Item -Path $key.PSPath -Force + if (!$default) { + Write-Output "Clearing default 'tilegrid'" + $tilegrid = Get-ChildItem -Path "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount" -Recurse | Where-Object { $_.Name -match "start.tilegrid" } + foreach ($key in $tilegrid) { + Remove-Item -Path $key.PSPath -Force + } } Write-Output "Removing advertisements/stubs from Start Menu (23H2+)" diff --git a/src/playbook/Executables/TASKBARPINS.ps1 b/src/playbook/Executables/TASKBARPINS.ps1 index 1842210814..c86dedd0e8 100644 --- a/src/playbook/Executables/TASKBARPINS.ps1 +++ b/src/playbook/Executables/TASKBARPINS.ps1 @@ -85,11 +85,11 @@ $taskBarLocation = 'Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar $rootKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband' # Clearing taskbar, copying the shortcut, setting registry -foreach ($userKey in (Get-RegUserPaths).PsPath) { +foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) { $sid = Split-Path $userKey -Leaf $appData = Get-ItemPropertyValue "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" -Name 'AppData' -EA 0 - if (!(Test-Path $appData)) { + if ([string]::IsNullOrEmpty($appData) -or !(Test-Path $appData)) { Write-Error "Couldn't find AppData value for $sid!" } else { Write-Title "Setting '$Browser' taskbar shortcut for '$sid'..."