2026-06-21 01:56:28 +02:00
<#
. SYNOPSIS
Disables Microsoft Store search suggestions in the start menu for all user profiles.
. DESCRIPTION
Iterates over every existing user profile and the Default user profile,
denying the EVERYONE group FullControl access to each user's Store app
database file (store.db). This prevents Windows from showing Store search
suggestions in the start menu search pane.
. EXAMPLE
DisableStoreSearchSuggestionsForAllUsers
2026-08-22 17:14:09 +02:00
. OUTPUTS
System.Boolean. $true when a profile is processed and all ACL changes succeed; otherwise $false.
2026-06-21 01:56:28 +02:00
#>
2026-07-19 22:06:07 +02:00
function Set-StoreSearchSuggestionsDisabledForAllUsers {
2026-08-15 17:08:00 +02:00
$success = $true
$processedProfiles = 0
2026-03-07 20:28:48 +01:00
# Get path to Store app database for all users
2026-07-19 22:06:07 +02:00
$userPathString = Get-UserDirectory -userName "*" -fileName "AppData\Local\Packages"
2026-05-08 21:19:52 +02:00
$usersStoreDbPaths = Get-ChildItem -Path $userPathString -ErrorAction SilentlyContinue
2026-03-07 20:28:48 +01:00
# Go through all users and disable start search suggestions
2026-06-21 01:56:28 +02:00
foreach ( $storeDbPath in $usersStoreDbPaths ) {
2026-08-15 17:08:00 +02:00
$processedProfiles ++
if ( -not ( Set-StoreSearchSuggestionsDisabled -StoreAppsDatabase ( $storeDbPath . FullName + "\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db" ))) {
$success = $false
}
2026-03-07 20:28:48 +01:00
}
# Also disable start search suggestions for the default user profile
2026-07-19 22:06:07 +02:00
$defaultStoreDbPath = Get-StoreAppsDatabasePathForUser -UserName "Default"
2026-06-21 01:56:28 +02:00
if ( $defaultStoreDbPath ) {
2026-08-15 17:08:00 +02:00
$processedProfiles ++
if ( -not ( Set-StoreSearchSuggestionsDisabled -StoreAppsDatabase $defaultStoreDbPath )) {
$success = $false
}
2026-06-21 01:56:28 +02:00
}
2026-08-15 17:08:00 +02:00
if ( $processedProfiles -eq 0 ) {
Write-Warning 'Unable to disable Microsoft Store search suggestions because no target user profiles could be resolved.'
return $false
}
return $success
2026-03-07 20:28:48 +01:00
}
2026-06-21 01:56:28 +02:00
<#
. SYNOPSIS
Disables Microsoft Store search suggestions for a single user.
. DESCRIPTION
Denies the EVERYONE group FullControl access to the specified Store app
database file (store.db). If the file does not exist (e.g. on EEA systems
where Store app suggestions are absent by default), it creates the file
and its parent directory first to prevent Windows from recreating it later.
.PARAMETER StoreAppsDatabase
The full path to the user's store.db file.
. EXAMPLE
DisableStoreSearchSuggestions -StoreAppsDatabase "$env:LOCALAPPDATA\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db"
2026-08-22 17:14:09 +02:00
. OUTPUTS
System.Boolean. $true when the database ACL is restricted or previewed; otherwise $false.
2026-06-21 01:56:28 +02:00
#>
2026-07-19 22:06:07 +02:00
function Set-StoreSearchSuggestionsDisabled {
2026-03-07 20:28:48 +01:00
param (
2026-06-21 01:56:28 +02:00
[ Parameter ( Mandatory )]
[ string ] $StoreAppsDatabase
2026-03-07 20:28:48 +01:00
)
$userName = [ regex ]:: Match ( $StoreAppsDatabase , '(?:Users\\)([^\\]+)(?:\\AppData)' ). Groups [ 1 ]. Value
2026-06-21 01:56:28 +02:00
if ( -not $userName ) { $userName = '<unknown>' }
2026-03-07 20:28:48 +01:00
2026-06-22 02:30:31 +07:00
if ( $script:Params . ContainsKey ( "WhatIf" )) {
Write-Host "[WhatIf] Disable Microsoft Store search suggestions for user $userName by restricting access to ${StoreAppsDatabase} " -ForegroundColor Cyan
2026-08-15 17:08:00 +02:00
return $true
2026-06-22 02:30:31 +07:00
}
2026-08-15 17:08:00 +02:00
try {
# This file doesn't exist in EEA (No Store app suggestions).
if ( -not ( Test-Path -Path $StoreAppsDatabase )) {
Write-Host "Unable to find Store app database for user $userName , creating it now to prevent Windows from creating it later..." -ForegroundColor Yellow
2026-03-07 20:28:48 +01:00
2026-08-15 17:08:00 +02:00
$storeDbDir = Split-Path -Path $StoreAppsDatabase -Parent
if ( -not ( Test-Path -Path $storeDbDir )) {
New-Item -Path $storeDbDir -ItemType Directory -Force -ErrorAction Stop | Out-Null
}
2026-03-07 20:28:48 +01:00
2026-08-15 17:08:00 +02:00
New-Item -Path $StoreAppsDatabase -ItemType File -Force -ErrorAction Stop | Out-Null
2026-03-07 20:28:48 +01:00
}
2026-08-16 18:49:15 +02:00
$AccountSid = [ System.Security.Principal.SecurityIdentifier ]:: new ( 'S-1-1-0' ) # 'EVERYONE' group
$Acl = Get-Acl -Path $StoreAppsDatabase -ErrorAction Stop
$Ace = [ System.Security.AccessControl.FileSystemAccessRule ]:: new ( $AccountSid , 'FullControl' , 'Deny' )
$Acl . SetAccessRule ( $Ace ) | Out-Null
Set-Acl -Path $StoreAppsDatabase -AclObject $Acl -ErrorAction Stop | Out-Null
}
catch {
Write-Warning "Failed to restrict ACL for store database ' $StoreAppsDatabase ': $( $_ . Exception . Message ) "
2026-08-15 17:08:00 +02:00
return $false
2026-08-16 18:49:15 +02:00
}
2026-03-07 20:28:48 +01:00
Write-Host "Disabled Microsoft Store search suggestions for user $userName "
2026-08-15 17:08:00 +02:00
return $true
2026-06-10 17:40:31 +02:00
}
2026-06-21 01:56:28 +02:00
<#
. SYNOPSIS
Re-enables Microsoft Store search suggestions in the start menu for all user profiles.
. DESCRIPTION
Iterates over every existing user profile and the Default user profile,
removing the deny ACL from each user's Store app database file (store.db)
and then deleting the file. This restores the default Windows behavior
where Store search suggestions appear in the start menu.
. EXAMPLE
EnableStoreSearchSuggestionsForAllUsers
2026-08-22 17:14:09 +02:00
. OUTPUTS
System.Boolean. $true when a profile is processed and all ACL changes succeed; otherwise $false.
2026-06-21 01:56:28 +02:00
#>
2026-07-19 22:06:07 +02:00
function Set-StoreSearchSuggestionsEnabledForAllUsers {
2026-08-15 17:08:00 +02:00
$success = $true
$processedProfiles = 0
2026-06-10 17:40:31 +02:00
# Get path to Store app database for all users
2026-07-19 22:06:07 +02:00
$userPathString = Get-UserDirectory -userName "*" -fileName "AppData\Local\Packages"
2026-06-10 17:40:31 +02:00
$usersStoreDbPaths = Get-ChildItem -Path $userPathString -ErrorAction SilentlyContinue
# Go through all users and re-enable start search suggestions
2026-06-21 01:56:28 +02:00
foreach ( $storeDbPath in $usersStoreDbPaths ) {
2026-08-15 17:08:00 +02:00
$processedProfiles ++
if ( -not ( Set-StoreSearchSuggestionsEnabled -StoreAppsDatabase ( $storeDbPath . FullName + "\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db" ))) {
$success = $false
}
2026-06-10 17:40:31 +02:00
}
# Also re-enable for the default user profile
2026-07-19 22:06:07 +02:00
$defaultStoreDbPath = Get-StoreAppsDatabasePathForUser -UserName "Default"
2026-06-21 01:56:28 +02:00
if ( $defaultStoreDbPath ) {
2026-08-15 17:08:00 +02:00
$processedProfiles ++
if ( -not ( Set-StoreSearchSuggestionsEnabled -StoreAppsDatabase $defaultStoreDbPath )) {
$success = $false
}
2026-06-21 01:56:28 +02:00
}
2026-08-15 17:08:00 +02:00
if ( $processedProfiles -eq 0 ) {
Write-Warning 'Unable to re-enable Microsoft Store search suggestions because no target user profiles could be resolved.'
return $false
}
return $success
2026-06-10 17:40:31 +02:00
}
2026-06-21 01:56:28 +02:00
<#
. SYNOPSIS
Re-enables Microsoft Store search suggestions for a single user.
. DESCRIPTION
Takes ownership of the specified Store app database file, removes any
EVERYONE deny FullControl ACL entries, and deletes the file. If the file
does not exist, no action is taken. Callers should handle the case where
the file is absent gracefully.
.PARAMETER StoreAppsDatabase
The full path to the user's store.db file.
. EXAMPLE
EnableStoreSearchSuggestions -StoreAppsDatabase "$env:LOCALAPPDATA\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db"
2026-08-22 17:14:09 +02:00
. OUTPUTS
System.Boolean. $true when the deny ACL is removed, the database is absent, or the change is previewed; otherwise $false.
2026-06-21 01:56:28 +02:00
#>
2026-07-19 22:06:07 +02:00
function Set-StoreSearchSuggestionsEnabled {
2026-06-10 17:40:31 +02:00
param (
2026-06-21 01:56:28 +02:00
[ Parameter ( Mandatory )]
[ string ] $StoreAppsDatabase
2026-06-10 17:40:31 +02:00
)
$userName = [ regex ]:: Match ( $StoreAppsDatabase , '(?:Users\\)([^\\]+)(?:\\AppData)' ). Groups [ 1 ]. Value
if ( -not $userName ) { $userName = '<unknown>' }
2026-06-22 02:30:31 +07:00
if ( $script:Params . ContainsKey ( "WhatIf" )) {
Write-Host "[WhatIf] Re-enable Microsoft Store search suggestions for user $userName by restoring access to ${StoreAppsDatabase} " -ForegroundColor Cyan
2026-08-15 17:08:00 +02:00
return $true
2026-06-22 02:30:31 +07:00
}
2026-06-10 17:40:31 +02:00
if ( -not ( Test-Path -Path $StoreAppsDatabase )) {
Write-Host "Store app database not found for user $userName , nothing to undo"
2026-08-15 17:08:00 +02:00
return $true
2026-06-10 17:40:31 +02:00
}
# Ensure we can modify/delete the file even if restrictive ACLs were set.
$global:LASTEXITCODE = 0
takeown / F " $StoreAppsDatabase " / A | Out-Null
2026-08-15 17:08:00 +02:00
if ( $LASTEXITCODE -ne 0 ) {
Write-Warning "Failed to take ownership of store database ' $StoreAppsDatabase ' while undoing Microsoft Store search suggestions. Exit code: $LASTEXITCODE "
return $false
}
2026-06-10 17:40:31 +02:00
icacls " $StoreAppsDatabase " / grant * S - 1 - 5 - 32 - 544 : F / C | Out-Null
2026-08-15 17:08:00 +02:00
if ( $LASTEXITCODE -ne 0 ) {
Write-Warning "Failed to grant Administrators access to store database ' $StoreAppsDatabase ' while undoing Microsoft Store search suggestions. Exit code: $LASTEXITCODE "
return $false
}
2026-06-10 17:40:31 +02:00
$everyoneSid = [ System.Security.Principal.SecurityIdentifier ]:: new ( 'S-1-1-0' ) # 'EVERYONE' group
try {
2026-08-15 17:08:00 +02:00
$acl = Get-Acl -Path $StoreAppsDatabase -ErrorAction Stop
2026-06-10 17:40:31 +02:00
$denyRules = @ (
$acl . Access | Where-Object {
2026-07-04 18:57:50 +07:00
if ( $_ . AccessControlType -ne [ System.Security.AccessControl.AccessControlType ]:: Deny ) { return $false }
if (( $_ . FileSystemRights -band [ System.Security.AccessControl.FileSystemRights ]:: FullControl ) -eq 0 ) { return $false }
try {
return ( $_ . IdentityReference . Translate ([ System.Security.Principal.SecurityIdentifier ]) -eq $everyoneSid )
}
catch {
return $false
}
2026-06-10 17:40:31 +02:00
}
)
foreach ( $denyRule in $denyRules ) {
$null = $acl . RemoveAccessRuleSpecific ( $denyRule )
}
2026-08-15 17:08:00 +02:00
Set-Acl -Path $StoreAppsDatabase -AclObject $acl -ErrorAction Stop | Out-Null
2026-06-10 17:40:31 +02:00
}
catch {
Write-Warning "Failed to normalize ACL for store database ' $StoreAppsDatabase ': $( $_ . Exception . Message ) "
}
try {
Remove-Item -Path $StoreAppsDatabase -Force -ErrorAction Stop
Write-Host "Re-enabled Microsoft Store search suggestions for user $userName "
2026-08-15 17:08:00 +02:00
return $true
2026-06-10 17:40:31 +02:00
}
catch {
2026-08-15 17:08:00 +02:00
Write-Warning "Failed to remove ' $StoreAppsDatabase ' while undoing Microsoft Store search suggestions for user $userName . $( $_ . Exception . Message ) "
return $false
2026-06-10 17:40:31 +02:00
}
}
2026-06-21 01:56:28 +02:00
<#
. SYNOPSIS
Returns the full path to the Store app database file for a given user.
. DESCRIPTION
Resolves the path to the Microsoft Store app database (store.db) for the
specified username. When no username is provided or the value is empty,
falls back to the current user's local app data path via $env:LOCALAPPDATA.
.PARAMETER UserName
The target username. Pass an empty string or omit to resolve for the current user.
. EXAMPLE
2026-07-19 22:06:07 +02:00
Get-StoreAppsDatabasePathForUser -UserName "Jeff"
2026-06-21 01:56:28 +02:00
. EXAMPLE
2026-07-19 22:06:07 +02:00
Get-StoreAppsDatabasePathForUser -UserName "Default"
2026-06-21 01:56:28 +02:00
#>
2026-07-19 22:06:07 +02:00
function Get-StoreAppsDatabasePathForUser {
2026-06-21 01:56:28 +02:00
param (
[ string ] $UserName
)
if ([ string ]:: IsNullOrWhiteSpace ( $UserName )) {
return " $env:LOCALAPPDATA \Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db"
}
2026-07-19 22:06:07 +02:00
return ( Get-UserDirectory -userName $UserName -fileName "AppData\Local\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db" -exitIfPathNotFound $false )
2026-06-21 01:56:28 +02:00
}
<#
. SYNOPSIS
Tests whether Store search suggestions are disabled for a single user.
. DESCRIPTION
Checks whether the specified store.db file has an EVERYONE deny
FullControl ACL entry applied. Returns $true if the deny rule is present,
$false otherwise (including when the file or directory does not exist).
.PARAMETER StoreAppsDatabase
The full path to the user's store.db file.
. EXAMPLE
Test-StoreSearchSuggestionsDisabled -StoreAppsDatabase "C:\Users\Jeff\AppData\Local\Packages\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db"
#>
2026-06-10 17:40:31 +02:00
function Test-StoreSearchSuggestionsDisabled {
param (
[ Parameter ( Mandatory )]
[ string ] $StoreAppsDatabase
)
if ( -not ( Test-Path -Path $StoreAppsDatabase )) {
return $false
}
try {
$acl = Get-Acl -Path $StoreAppsDatabase
}
catch {
return $false
}
$everyoneSid = [ System.Security.Principal.SecurityIdentifier ]:: new ( 'S-1-1-0' )
foreach ( $accessRule in @ ( $acl . Access )) {
$isDenyFullControl = $accessRule . AccessControlType -eq [ System.Security.AccessControl.AccessControlType ]:: Deny -and
(( $accessRule . FileSystemRights -band [ System.Security.AccessControl.FileSystemRights ]:: FullControl ) -ne 0 )
if ( -not $isDenyFullControl ) { continue }
$isEveryone = $false
try {
$isEveryone = $accessRule . IdentityReference . Translate ([ System.Security.Principal.SecurityIdentifier ]) -eq $everyoneSid
2026-06-22 02:30:31 +07:00
}
catch { }
2026-06-10 17:40:31 +02:00
if ( $isEveryone ) {
return $true
}
}
return $false
}
2026-06-21 01:56:28 +02:00
<#
. SYNOPSIS
Tests whether Store search suggestions are disabled for all user profiles.
. DESCRIPTION
Collects the store.db paths for all existing user profiles and the Default
user profile, then verifies that every one of them has the EVERYONE deny
FullControl ACL applied. Returns $true only if ALL paths pass the check.
Returns $false immediately if any user's store.db is not disabled.
. EXAMPLE
Test-StoreSearchSuggestionsDisabledForAllUsers
#>
2026-06-10 17:40:31 +02:00
function Test-StoreSearchSuggestionsDisabledForAllUsers {
$paths = @ ()
2026-07-19 22:06:07 +02:00
$userPathString = Get-UserDirectory -userName "*" -fileName "AppData\Local\Packages"
2026-06-10 17:40:31 +02:00
$usersStoreDbPaths = Get-ChildItem -Path $userPathString -ErrorAction SilentlyContinue
foreach ( $storeDbPath in $usersStoreDbPaths ) {
$paths += ( $storeDbPath . FullName + "\Microsoft.WindowsStore_8wekyb3d8bbwe\LocalState\store.db" )
}
2026-07-19 22:06:07 +02:00
$defaultStoreDbPath = Get-StoreAppsDatabasePathForUser -UserName "Default"
2026-06-10 17:40:31 +02:00
if ( $defaultStoreDbPath ) {
$paths += $defaultStoreDbPath
}
if ( $paths . Count -eq 0 ) {
return $false
}
foreach ( $path in $paths ) {
if ( -not ( Test-StoreSearchSuggestionsDisabled -StoreAppsDatabase $path )) {
return $false
}
}
return $true
2026-07-19 22:06:07 +02:00
}