forked from microsoft/Code-Search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResumeIndexing.ps1
72 lines (63 loc) · 2.18 KB
/
ResumeIndexing.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True, Position=0, HelpMessage="The Server Instance against which the script is to run.")]
[string]$SQLServerInstance,
[Parameter(Mandatory=$True, Position=1, HelpMessage="Configuration DB")]
[string]$ConfigurationDatabaseName,
[Parameter(Mandatory=$False, Position=2, HelpMessage="Resume Indexing for Code, WorkItem or All")]
[string]$EntityType = "All"
)
function ResumeCodeIndexing
{
$SqlFullPath = Join-Path $PWD -ChildPath 'SqlScripts\ResumeCodeIndexing.sql'
Invoke-Sqlcmd -InputFile $SqlFullPath -serverInstance $SQLServerInstance -database $ConfigurationDatabaseName
Write-Host "Code Indexing has been resumed!!" -ForegroundColor Green
}
function ResumeWorkItemIndexing
{
$SqlFullPath = Join-Path $PWD -ChildPath 'SqlScripts\ResumeWorkItemIndexing.sql'
Invoke-Sqlcmd -InputFile $SqlFullPath -serverInstance $SQLServerInstance -database $ConfigurationDatabaseName
Write-Host "WorkItem Indexing has been resumed!!" -ForegroundColor Green
}
function ImportSQLModule
{
$moduleCheck = Get-Module -List SQLPS
if($moduleCheck)
{
Import-Module -Name SQLPS -DisableNameChecking
Write-Host "Loaded SQLPS module..." -ForegroundColor Green
}
else
{
Write-Error "Cannot load module SQLPS. Please try from a machine running SQL Server 2012 or higher."
Pop-Location
exit
}
}
[System.ENVIRONMENT]::CurrentDirectory = $PWD
Push-Location
ImportSQLModule
switch ($EntityType)
{
"All"
{
Write-Host "Resuming indexing for Code and WorkItem..." -ForegroundColor Green
ResumeCodeIndexing
ResumeWorkItemIndexing
}
"WorkItem"
{
Write-Host "Resuming indexing for WorkItem..." -ForegroundColor Green
ResumeWorkItemIndexing
}
"Code"
{
Write-Host "Resuming indexing for Code..." -ForegroundColor Green
ResumeCodeIndexing
}
default
{
Write-Host "Enter a valid EntityType i.e. Code or WorkItem or All" -ForegroundColor Red
}
}
Pop-Location