PoshCode Logo PowerShell Code Repository

Rebuild Windows Indexing by Frank 6 weeks ago (modification of post by Aphexenator view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/6662"></script>download | new post

Rebuilds Windows Indexing on a remote PC

  1. #Capture the PC Name
  2. $PCNAME = Read-Host -Prompt "Which is the user's PC?"
  3. #Test the Connection
  4. $PING = (test-connection $PCNAME -count 1 -quiet)
  5.     If ( $PING -eq $false)
  6.         {
  7.         Write-Host "Connection Failed"
  8.         return
  9.         }
  10.  
  11.  
  12. # Stop wsearch
  13. (Get-Service -Name wsearch -ComputerName $PCNAME).stop()
  14. Write-Host "Windows search service has stopped"
  15.  
  16. # Delete Index database
  17. start-sleep -seconds 5
  18. C:\Windows\psexec -s \\$PCNAME cmd /c del "%ProgramData%\Microsoft\Search\Data\Applications\Windows\Windows.edb"
  19.  
  20. # Start wsearch
  21.  
  22. (Get-Service -Name wsearch -ComputerName $PCNAME).start()
  23. Write-Host "Windows search service has started"
  24.  
  25. C:\Windows\PsExec.exe -s \\$PCNAME msg * /w "The windows indexing service has restarted, the database can take up to 7 days to rebuild."
  26. Write-Host "The windows indexing service has restarted, the database can take up to 7 days to rebuild."

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me