-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDownloadAdventureWorks.ps1
33 lines (31 loc) · 1.07 KB
/
DownloadAdventureWorks.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
$ErrorActionPreference = 'Stop'
try
{
$cloneDir = 'C:\TestData'
New-Item -Path $cloneDir -ItemType Directory | Out-Null
Push-Location $cloneDir
Write-Host "git clone -q -n https://github.com/Microsoft/sql-server-samples"
git clone -q -n https://github.com/Microsoft/sql-server-samples 2>&1 | ForEach-Object { $_.ToString() }
Set-Location sql-server-samples
Write-Host "git config core.sparsecheckout true"
git config core.sparsecheckout true 2>&1 | ForEach-Object { $_.ToString() }
Write-Host "git config core.autocrlf true"
git config core.autocrlf true 2>&1 | ForEach-Object { $_.ToString() }
'samples/databases/adventure-works/*' | Out-File -Append -Encoding ascii .git/info/sparse-checkout
Write-Host "git checkout -q"
git checkout -q 2>&1 | ForEach-Object { $_.ToString() }
if (-not (Test-Path -Path (Join-Path $cloneDir 'sql-server-samples\samples\databases\adventure-works\oltp-install-script')))
{
throw 'AdventureWorks not cloned as expected'
}
}
catch
{
Write-Host -ForegroundColor Red $_.Exception.Message
$_.ScriptStackTrace
exit 1
}
finally
{
Pop-Location
}