PoshCode Archive  Artifact [d390b37509]

Artifact d390b37509b8d3d437746fece85475b2165ba04428cd965cc2da29403b151ca7:

  • File Rebuild-Windows-Indexing.ps1 — part of check-in [3f3670abbd] at 2018-06-10 14:07:41 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: 6083
# x-archived: 2017-03-20T23:12:04
# x-published: 2017-11-06T22:29: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."