PoshCode Archive  Artifact [1ed7ad8a7e]

Artifact 1ed7ad8a7e39ae11946e514e3e2bd8483c00996564c394a796fcf2293b1cf20a:

  • File Rebuild-Windows-Indexing.ps1 — part of check-in [d5d036c1af] at 2018-06-10 14:19:09 on branch trunk — Rebuilds Windows Indexing on a remote PC (user: Aphexenator size: 1207)

# encoding: ascii
# api: powershell
# title: Rebuild Windows Indexing
# description: Rebuilds Windows Indexing on a remote PC
# version: 0.1
# author: Aphexenator
# license: CC0
# x-poshcode-id: 6662
# x-archived: 2017-01-09T07:31:50
# x-published: 2017-01-03T19:08:00
#
#
#Capture the PC Name
$PCNAME = Read-Host -Prompt "Which is the user's PC?"
#Test the Connection
$PING = (test-connection $PCNAME -count 1 -quiet)
    If ( $PING -eq $false)
        {
        Write-Host "Connection Failed"
        return
        }


# Stop wsearch
(Get-Service -Name wsearch -ComputerName $PCNAME).stop()
Write-Host "Windows search service has stopped"

# Delete Index database
start-sleep -seconds 5
C:\Windows\psexec -s \\$PCNAME cmd /c del "%ProgramData%\Microsoft\Search\Data\Applications\Windows\Windows.edb"

# Start wsearch

(Get-Service -Name wsearch -ComputerName $PCNAME).start()
Write-Host "Windows search service has started"

C:\Windows\PsExec.exe -s \\$PCNAME msg * /w "The windows indexing service has restarted, the database can take up to 7 days to rebuild."
Write-Host "The windows indexing service has restarted, the database can take up to 7 days to rebuild."