diff --git a/README.md b/README.md index 9de6c8d..d88431b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Scripts/QuickRun.ps1 b/Scripts/QuickRun.ps1 index af4be33..211fb80 100644 --- a/Scripts/QuickRun.ps1 +++ b/Scripts/QuickRun.ps1 @@ -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" @@ -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" @@ -32,4 +46,4 @@ CreateFolderIfNotExists $ContosoDatasetFolder CreateFolderIfNotExists $DatasetOutputFolder CreateFolderIfNotExists $SqlBackupFolder -.\GenerateDatabases.ps1 -SqlDataFilesFolder $SqlDataFilesFolder -SqlBackupFolder $SqlBackupFolder -DatasetOutputFolder $DatasetOutputFolder \ No newline at end of file +.\GenerateDatabases.ps1 -SqlDataFilesFolder $SqlDataFilesFolder -SqlBackupFolder $SqlBackupFolder -DatasetOutputFolder $DatasetOutputFolder -SqlServerInstance $SqlServerInstance \ No newline at end of file diff --git a/Scripts/README.md b/Scripts/README.md index 91c130a..b9dfa4f 100644 --- a/Scripts/README.md +++ b/Scripts/README.md @@ -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