Users may experience an issue where searching for file names longer than four characters on a network results in indefinite loading. This issue is not observed on other PCs within the same network.
To resolve this issue, follow these steps to run a PowerShell script that resets the Windows search components and clears related caches. This process requires running the script with administrative privileges and setting the execution policy.
Set the PowerShell Execution Policy: Before running the script, you need to set the execution policy to allow the script to run. Open PowerShell as an administrator and execute the following command:
powershellSet-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
PowerShell Script to Resolve Network Search Issue:
Use the following PowerShell script. Save the script as a .ps1
file, for example, Reset-Search.ps1
.
powershell# Function Definitions function T-R { [CmdletBinding()] Param( [String] $n ) $o = Get-Item -LiteralPath $n -ErrorAction SilentlyContinue return ($o -ne $null) } function R-R { [CmdletBinding()] Param( [String] $l ) $m = T-R $l if ($m) { Remove-Item -Path $l -Recurse -ErrorAction SilentlyContinue } } function S-D { R-R "HKLM:\SOFTWARE\Microsoft\Cortana\Testability" R-R "HKLM:\SOFTWARE\Microsoft\Search\Testability" } function K-P { [CmdletBinding()] Param( [String] $g ) $h = Get-Process $g -ErrorAction SilentlyContinue $i = $(get-date).AddSeconds(2) $k = $(get-date) while ((($i - $k) -gt 0) -and $h) { $k = $(get-date) $h = Get-Process $g -ErrorAction SilentlyContinue if ($h) { $h.CloseMainWindow() | Out-Null Stop-Process -Id $h.Id -Force } $h = Get-Process $g -ErrorAction SilentlyContinue } } function D-FF { [CmdletBinding()] Param( [string[]] $e ) foreach ($f in $e) { if (Test-Path -Path $f) { Remove-Item -Recurse -Force $f -ErrorAction SilentlyContinue } } } function D-W { $d = @("$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\AppCache", "$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\INetCache", "$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\INetCookies", "$Env:localappdata\Packages\Microsoft.Cortana_8wekyb3d8bbwe\AC\INetHistory", "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\AppCache", "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\INetCache", "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\INetCookies", "$Env:localappdata\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\INetHistory", "$Env:localappdata\Packages\Microsoft.Search_8wekyb3d8bbwe\AC\AppCache", "$Env:localappdata\Packages\Microsoft.Search_8wekyb3d8bbwe\AC\INetCache", "$Env:localappdata\Packages\Microsoft.Search_8wekyb3d8bbwe\AC\INetCookies", "$Env:localappdata\Packages\Microsoft.Search_8wekyb3d8bbwe\AC\INetHistory", "$Env:localappdata\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AC\AppCache", "$Env:localappdata\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AC\INetCache", "$Env:localappdata\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AC\INetCookies", "$Env:localappdata\Packages\Microsoft.Windows.Search_cw5n1h2txyewy\AC\INetHistory") D-FF $d } function R-L { [CmdletBinding()] Param( [String] $c ) K-P $c 2>&1 | out-null D-W # 2>&1 | out-null K-P $c 2>&1 | out-null Start-Sleep -s 5 } function D-E { Write-Host "Press Enter to continue..." [void][System.Console]::ReadLine() } Write-Output "Verifying that the script is running elevated" if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) { $Cx = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList "-noexit",$Cx Exit } } $a = "searchui" $b = "$Env:localappdata\Packages\Microsoft.Windows.Search_cw5n1h2txyewy" if (Test-Path -Path $b) { $a = "searchapp" } Write-Output "Resetting Windows Search Box" S-D 2>&1 | out-null R-L $a Write-Output "Done..." D-E
Run the PowerShell Script:
.ps1
file and select "Run with PowerShell."Monitor the Results:
By following these steps, you should be able to resolve the network search issue on the affected PC. If you encounter any further issues or need assistance, please contact the IT support team.