Skip to content

Commit

Permalink
improved Readme files, implemented new parameter SqlServerInstance fo…
Browse files Browse the repository at this point in the history
…r QuickRun.ps1
  • Loading branch information
SergioMurru committed Jul 6, 2022
1 parent dca2733 commit aa67aae
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ To quickly test the tool, verify the pre-requisites and run the QuickRun.ps1 scr
### Pre-requisite to run the tool

- 7-Zip [https://www.7-zip.org/](https://www.7-zip.org/)
- Microsoft SQL Server must be installed on the same PC, reachable through the Alias **Demo**
- Microsoft SQL Server must be installed on the same PC, reachable through the Alias **Demo**. You can download SQL Server Developer (free edition, licensed for use as a development and test database in a non-production environment) at [https://www.microsoft.com/en-us/sql-server/sql-server-downloads](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)
- The user running Microsoft SQL Server service must have access to the **SqlDataFiles** folder (default C:\TEMP) used by the PowerShell script (see following section)
- .Net Core 3.1 [https://dotnet.microsoft.com/en-us/download/dotnet/3.1](https://dotnet.microsoft.com/en-us/download/dotnet/3.1)

### Running QuickRun.ps1

QuickRun.ps1 takes one optional parameter
QuickRun.ps1 takes two optional parameters

- **SqlDataFilesFolder** (default C:\TEMP): the folder to contain the generated files. The user of the SQL Server service must have access to this folder with the rights to read, write and create files.
- **SqlDataFilesFolder** (default C:\TEMP): the folder to contain the generated files. The user running Microsoft SQL Server service must have access to the SqlDataFiles folder (default C:\TEMP). For more information read [https://www.mssqltips.com/sqlservertip/6930/issues-sql-server-permissions-restore-database/](https://www.mssqltips.com/sqlservertip/6930/issues-sql-server-permissions-restore-database/)
- **SqlServerInstance** (Default Demo): the name of the SQL server instance. The default is the alias name Demo, that can be configured using the SQL Server Configuration Manager [https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/create-or-delete-a-server-alias-for-use-by-a-client](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/create-or-delete-a-server-alias-for-use-by-a-client)

QuickRun.ps1 runs GenerateDatabases.ps1 script. For further details, please refer to the documentation into the Scripts folder.
18 changes: 16 additions & 2 deletions Scripts/QuickRun.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
param(
[string]$SqlDataFilesFolder='C:\TEMP'
[string]$SqlDataFilesFolder='C:\TEMP',
[string]$SqlServerInstance='Demo'
)

Write-Host 'SqlDataFilesFolder:' $SqlDataFilesFolder
Write-Host 'SqlServerInstance:' $SqlServerInstance

if (! (Test-Path -Path $SqlDataFilesFolder))
{
Write-Output "$SqlDataFilesFolder does not exist. Aborting"
Expand All @@ -14,6 +18,16 @@ if (! $SqlDataFilesFolder)
Exit 1
}

try
{
Invoke-Sqlcmd -ServerInstance $SqlServerInstance -Query 'SELECT 1' -ConnectionTimeout 10 | Out-Null
}
catch
{
Write-Host 'Error connecting to SQL Server instance' $SqlServerInstance
Exit 1
}

[string]$ContosoDatasetFolder="$($SqlDataFilesFolder)\ContosoDataset"
[string]$DatasetOutputFolder="$($ContosoDatasetFolder)\DatasetSqlbi"
[string]$SqlBackupFolder="$($ContosoDatasetFolder)\SqlBackup"
Expand All @@ -32,4 +46,4 @@ CreateFolderIfNotExists $ContosoDatasetFolder
CreateFolderIfNotExists $DatasetOutputFolder
CreateFolderIfNotExists $SqlBackupFolder

.\GenerateDatabases.ps1 -SqlDataFilesFolder $SqlDataFilesFolder -SqlBackupFolder $SqlBackupFolder -DatasetOutputFolder $DatasetOutputFolder
.\GenerateDatabases.ps1 -SqlDataFilesFolder $SqlDataFilesFolder -SqlBackupFolder $SqlBackupFolder -DatasetOutputFolder $DatasetOutputFolder -SqlServerInstance $SqlServerInstance
8 changes: 8 additions & 0 deletions Scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

QuickRun purpose is to create the working folders and then run the **GenerateDatabase.ps1** script

it can be run in a PowerShell window in the Scripts folder with the command to accept default parameters:

.\QuickRun.ps1

Or to specify the parameters by replacing C:\MYTEMP and MySqlInstance with the actual values to be used:

.\QuickRun.ps1 -SqlDataFilesFolder C:\MYTEMP -SqlServerInstance MySqlInstance

## GenerateDatabases.ps1

Generate several Contoso databases per run, by iterating over an array of configuration paramters to run in sequence
Expand Down

0 comments on commit aa67aae

Please sign in to comment.