forked from DBTrenches/SqlCodeReview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
61 lines (44 loc) · 2.29 KB
/
install.ps1
File metadata and controls
61 lines (44 loc) · 2.29 KB
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
#Requires -RunAsAdministrator
$Disclaimer = "I am a lazy person"
$Disclaimer | clip # backspace to remove the linefeed from the console if pasting
$Acknowledgement = Read-Host "Type the following text in order to proceed: '$Disclaimer'"
If($Acknowledgement -eq $Disclaimer){
$CurrentRepoRoot = "$PSScriptRoot"
Push-Location
$ModuleDirectory = "$home\Documents\WindowsPowerShell\Modules"
if(-not (Test-Path $ModuleDirectory)){
Write-Warning "Creating PSModulePath target at '$ModuleDirectory'."
New-Item -ItemType Directory -Path $ModuleDirectory | Out-Null
}
Set-Location $ModuleDirectory
if(-not (Test-Path SqlCodeReview)){
Write-Warning "Downloading SqlCodeReview"
git clone https://github.com/petervandivier/SqlCodeReview.git
}
if(-not (Test-Path SqlCreateTable)){
Write-Warning "Downloading SqlCreateTable"
git clone https://github.com/petervandivier/SqlCreateTable.git
}
if($null -ne (Get-Module SQLPS -ListAvailable)){
Write-Warning "Removing SQLPS Module"
Remove-Module SQLPS -Force -ErrorAction SilentlyContinue
}
if($null -eq (Get-Module SqlServer -ListAvailable)){
Write-Warning "Downloading SqlServer Module"
Install-Module SqlServer -Force -ErrorAction SilentlyContinue
}
$DatabaseConfig = Get-Content "$CurrentRepoRoot/config/default.config.EXAMPLE.csv" | ConvertFrom-Csv
$ModuleConfig = Get-Content "$CurrentRepoRoot/config/default.config.EXAMPLE.json" | ConvertFrom-Json
$ModuleConfig.CodeReviewRepo.PSObject.Properties.Remove('MyOtherProject')
$ModuleConfig | ConvertTo-Json | Out-File $ModuleConfigPath -Encoding ascii -Force | Out-Null
$DatabaseConfig | Export-Csv -Path $ModuleConfig.EnvironmentConfigFile -Encoding ascii -Force -NoTypeInformation | Out-Null
Import-Module SqlCodeReview -Scope Global -Force
if(-not (test-path $profile.CurrentUserAllHosts)){
New-Item -type file -path $Profile.CurrentUserAllHosts -force | Out-Null
}
$myProfile = Get-Content $Profile.CurrentUserAllHosts -Raw
if($myProfile -notlike "*SqlCodeReview*"){
Add-Content -Path $Profile.CurrentUserAllHosts -Value "Import-Module SqlCodeReview"
}
Pop-Location
}