### Example of Completing SQL Server Image Installation Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Complete‑SqlDscImage This example demonstrates how to complete the image installation for the default SQL Server instance. Ensure the -MediaPath points to the correct installation media. ```powershell Complete-SqlDscImage -AcceptLicensingTerms -MediaPath 'E:\' -InstanceId 'MSSQLSERVER' -SqlSvcAccount 'NT Service\MSSQLSERVER' -AgtSvcAccount 'NT Service\MSSQLSERVER' ``` -------------------------------- ### Install-SqlDscServer -Install (Example) Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install-SqlDscServer Example of installing the database engine for a named instance. ```APIDOC ## EXAMPLE 1 ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE' -SqlSysAdminAccounts @('MyAdminAccount') -MediaPath 'E:\' ``` Installs the database engine for the named instance MyInstance. ``` -------------------------------- ### Example: Initialize Failover Cluster Installation Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Initialize‑SqlDscFailoverCluster Use this example to prepare for installing the SQL Server database engine in a failover cluster. Ensure you provide the correct instance name and media path. ```powershell Initialize-SqlDscFailoverCluster -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE' -MediaPath 'E:\' ``` -------------------------------- ### Install-SqlDscServer -Install with Azure Arc (Example) Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install-SqlDscServer Example of installing the database engine and onboarding to Azure Arc. ```APIDOC ## EXAMPLE 2 ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE','ARC' -SqlSysAdminAccounts @('MyAdminAccount') -MediaPath 'E:\' -AzureSubscriptionId 'MySubscriptionId' -AzureResourceGroup 'MyRG' -AzureRegion 'West-US' -AzureTenantId 'MyTenantId' -AzureServicePrincipal 'MyPrincipalName' -AzureServicePrincipalSecret ('MySecret' | ConvertTo-SecureString -AsPlainText -Force) ``` Installs the database engine for the named instance MyInstance and onboard the server to Azure Arc. ``` -------------------------------- ### Install-SqlDscServer -Install Azure Arc Agent (Example) Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install-SqlDscServer Example of installing the Azure Arc Agent on the server. ```APIDOC ## EXAMPLE 3 ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -MediaPath 'E:\' -AzureSubscriptionId 'MySubscriptionId' -AzureResourceGroup 'MyRG' -AzureRegion 'West-US' -AzureTenantId 'MyTenantId' -AzureServicePrincipal 'MyPrincipalName' -AzureServicePrincipalSecret ('MySecret' | ConvertTo-SecureString -AsPlainText -Force) ``` Installs the Azure Arc Agent on the server. ``` -------------------------------- ### Install SQL Server Using Configuration File Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscServer Example of installing SQL Server by referencing a configuration file. This is a common method for automated and consistent deployments. ```powershell Install-SqlDscServer -ConfigurationFile 'MySqlConfig.ini' -MediaPath 'E:\' ``` -------------------------------- ### Get Report Server Installations using Stored Configuration Object Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Get‑SqlDscRSDatabaseInstallation This example demonstrates how to get report server installations by first storing the configuration object obtained from `Get-SqlDscRSConfiguration` in a variable, and then passing that variable to the `-Configuration` parameter of `Get-SqlDscRSDatabaseInstallation`. ```powershell $config = Get-SqlDscRSConfiguration -InstanceName 'SSRS' Get-SqlDscRSDatabaseInstallation -Configuration $config ``` -------------------------------- ### Install-SqlDscServer - Install Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscServer Executes an install action using Microsoft SQL Server setup executable. This method requires the -Install parameter and accepts various parameters for customization. ```APIDOC ## Install-SqlDscServer - Install ### Description Executes an install action using Microsoft SQL Server setup executable. This method requires the -Install parameter and accepts various parameters for customization. ### Method Install-SqlDscServer ### Parameters #### Path Parameters - **Install** (SwitchParameter) - Required parameter to initiate the installation process. - **AcceptLicensingTerms** (SwitchParameter) - Required parameter to acknowledge license terms. - **MediaPath** (String) - Required parameter specifying the location of the SQL Server installation media. - **InstanceName** (String) - Specifies the name of the SQL Server instance to install. - **Features** (String[]) - Specifies the SQL Server features to install. - **SqlSysAdminAccounts** (String[]) - Specifies the accounts to be added to the SQL Server sysadmin role. - **AzureSubscriptionId** (String) - Specifies the Azure subscription ID for Azure Arc onboarding. - **AzureResourceGroup** (String) - Specifies the Azure resource group for Azure Arc onboarding. - **AzureRegion** (String) - Specifies the Azure region for Azure Arc onboarding. - **AzureTenantId** (String) - Specifies the Azure tenant ID for Azure Arc onboarding. - **AzureServicePrincipal** (String) - Specifies the service principal name for Azure Arc onboarding. - **AzureServicePrincipalSecret** (SecureString) - Specifies the secret for the Azure service principal. ### Request Example ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE' -SqlSysAdminAccounts @('MyAdminAccount') -MediaPath 'E:\' ``` ### Request Example (Azure Arc) ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE','ARC' -SqlSysAdminAccounts @('MyAdminAccount') -MediaPath 'E:\' -AzureSubscriptionId 'MySubscriptionId' -AzureResourceGroup 'MyRG' -AzureRegion 'West-US' -AzureTenantId 'MyTenantId' -AzureServicePrincipal 'MyPrincipalName' -AzureServicePrincipalSecret ('MySecret' | ConvertTo-SecureString -AsPlainText -Force) ``` ### Request Example (Azure Arc Agent Only) ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -MediaPath 'E:\' -AzureSubscriptionId 'MySubscriptionId' -AzureResourceGroup 'MyRG' -AzureRegion 'West-US' -AzureTenantId 'MyTenantId' -AzureServicePrincipal 'MyPrincipalName' -AzureServicePrincipalSecret ('MySecret' | ConvertTo-SecureString -AsPlainText -Force) ``` ``` -------------------------------- ### Install SQL Server Database Engine Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscServer Example of installing the SQL Server database engine for a named instance. Ensure the MediaPath points to the SQL Server installation media. ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE' -SqlSysAdminAccounts @('MyAdminAccount') -MediaPath 'E:\' ``` -------------------------------- ### Retrieve Default SQL Server Setup Log Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Get‑SqlDscSetupLog Use this command to get the most recent SQL Server setup log from the default installation path. No parameters are needed for this basic usage. ```powershell Get-SqlDscSetupLog ``` -------------------------------- ### Get All RS Setup Configurations Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Get‑SqlDscRSSetupConfiguration Use this command to retrieve configuration details for all installed SQL Server Reporting Services and Power BI Report Server instances on the system. No parameters are needed for this operation. ```powershell Get-SqlDscRSSetupConfiguration ``` -------------------------------- ### Install-SqlDscServer - ConfigurationFile Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscServer Executes an install action using Microsoft SQL Server setup executable with a configuration file. This method requires the -ConfigurationFile parameter. ```APIDOC ## Install-SqlDscServer - ConfigurationFile ### Description Executes an install action using Microsoft SQL Server setup executable with a configuration file. This method requires the -ConfigurationFile parameter. ### Method Install-SqlDscServer ### Parameters #### Path Parameters - **ConfigurationFile** (String) - Required parameter specifying the path to the SQL Server configuration file. - **MediaPath** (String) - Required parameter specifying the location of the SQL Server installation media. ### Request Example ```powershell Install-SqlDscServer -ConfigurationFile 'MySqlConfig.ini' -MediaPath 'E:\' ``` ``` -------------------------------- ### Example: Rebuild SQL Server Instance Databases Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Initialize-SqlDscRebuildDatabase This example demonstrates how to rebuild the system databases for an SQL Server instance named 'MyInstance'. Ensure the MediaPath points to the SQL Server installation media and SqlSysAdminAccounts is correctly specified. ```powershell Initialize-SqlDscRebuildDatabase -InstanceName 'MyInstance' -SqlSysAdminAccounts @('MyAdminAccount') -MediaPath 'E:\' ``` -------------------------------- ### Install-SqlDscPowerBIReportServer Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscPowerBIReportServer Installs SQL Server Power BI Report Server. This cmdlet requires the path to the setup executable and accepts various parameters to customize the installation, such as accepting license terms, specifying a product key, edition, installation folder, and log path. ```APIDOC ## Install-SqlDscPowerBIReportServer ### Description Installs SQL Server Power BI Report Server using the provided setup executable. ### Syntax ```powershell Install-SqlDscPowerBIReportServer [-AcceptLicensingTerms] -MediaPath [[-ProductKey] ] [-EditionUpgrade] [[-Edition] ] [[-LogPath] ] [[-InstallFolder] ] [-SuppressRestart] [[-Timeout] ] [-Force] [-PassThru] [-WhatIf] [-Confirm] [] ``` ### Parameters #### -AcceptLicensingTerms Specifies that the acceptance of all license terms and notices for the specified features is required to be able to run unattended install. By specifying this parameter you acknowledge the acceptance of all license terms and notices for the specified features, the terms and notices that the setup executable normally asks for. - Type: SwitchParameter - Required: True - Position: Named - Default value: False #### -MediaPath Specifies the path where to find the SQL Server installation media. On this path the SQL Server setup executable must be found. - Type: String - Required: True - Position: 1 #### -ProductKey Specifies the product key for the installation. - Type: String - Required: False - Position: 2 #### -EditionUpgrade Specifies whether to upgrade the edition of the installed product. Requires that either the ProductKey or the Edition parameter is also assigned. By default no edition upgrade is performed. - Type: SwitchParameter - Required: False - Position: Named - Default value: False #### -Edition Specifies a free custom edition to use for the installation. This parameter is mutually exclusive with the parameter ProductKey. - Type: String - Required: False - Position: 3 #### -LogPath Specifies the file path where to write the log files, e.g. 'C:\Logs\Install.log'. By default log files are created under %TEMP%. - Type: String - Required: False - Position: 4 #### -InstallFolder Specifies the folder where to install the product, e.g. 'C:\Program Files\Power BI Report Server'. By default the product is installed under the default installation folder. - Type: String - Required: False - Position: 5 #### -SuppressRestart Suppresses the automatic restart of the system after installation. - Type: SwitchParameter - Required: False - Position: Named - Default value: False #### -Timeout Specifies the timeout in seconds for the installation process. - Type: UInt32 - Required: False - Position: Named #### -Force Specifies whether the command will not ask for confirmation. Same as if Confirm:$false is used. - Type: SwitchParameter - Required: False - Position: Named - Default value: False #### -PassThru Specifies whether the command will return the setup process exit code. - Type: SwitchParameter - Required: False - Position: Named - Default value: False #### -WhatIf Performs the operation without actually performing the changes. What if the command could be run without actually running it or creating delete objects. The objects that would be created or deleted by the command are shown. These objects are not created or deleted and no other operations are performed. No message is displayed when -WhatIf is used. Regardless of the value passed to WhatIf, the behavior is the same. - Type: SwitchParameter - Required: False - Position: Named #### -Confirm Prompts you for confirmation before running the cmdlet. - Type: SwitchParameter - Required: False - Position: Named ### Examples #### EXAMPLE 1 ```powershell Install-SqlDscPowerBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' ``` Installs Power BI Report Server with default settings. #### EXAMPLE 2 ```powershell Install-SqlDscPowerBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -ProductKey '12345-12345-12345-12345-12345' ``` Installs Power BI Report Server using a product key. #### EXAMPLE 3 ```powershell Install-SqlDscPowerBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -Edition 'Evaluation' -InstallFolder 'C:\Program Files\Power BI Report Server' ``` Installs Power BI Report Server in evaluation edition to a custom folder. #### EXAMPLE 4 ```powershell Install-SqlDscPowerBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -ProductKey '12345-12345-12345-12345-12345' -EditionUpgrade -LogPath 'C:\Logs\PowerBIReportServer_Install.log' ``` Installs Power BI Report Server and upgrades the edition using a product key. Also specifies a custom log path. #### EXAMPLE 5 ```powershell $exitCode = Install-SqlDscPowerBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -PassThru ``` Installs Power BI Report Server with default settings and returns the setup exit code. ``` -------------------------------- ### Install Azure Arc Agent Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscServer Example of installing only the Azure Arc Agent on the server. This command does not install SQL Server components but prepares the server for Azure management. ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -MediaPath 'E:\' -AzureSubscriptionId 'MySubscriptionId' -AzureResourceGroup 'MyRG' -AzureRegion 'West-US' -AzureTenantId 'MyTenantId' -AzureServicePrincipal 'MyPrincipalName' -AzureServicePrincipalSecret ('MySecret' | ConvertTo-SecureString -AsPlainText -Force) ``` -------------------------------- ### Install SQL Server Database Engine and Onboard to Azure Arc Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscServer Example of installing the SQL Server database engine and simultaneously onboarding the server to Azure Arc. This requires providing Azure-specific connection details. ```powershell Install-SqlDscServer -Install -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE','ARC' -SqlSysAdminAccounts @('MyAdminAccount') -MediaPath 'E:\' -AzureSubscriptionId 'MySubscriptionId' -AzureResourceGroup 'MyRG' -AzureRegion 'West-US' -AzureTenantId 'MyTenantId' -AzureServicePrincipal 'MyPrincipalName' -AzureServicePrincipalSecret ('MySecret' | ConvertTo-SecureString -AsPlainText -Force) ``` -------------------------------- ### Install Power BI Report Server with Default Settings Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscBIReportServer Use this command to perform a default installation of Power BI Report Server. Ensure you accept the license terms and provide the correct path to the setup executable. ```powershell Install-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' ``` -------------------------------- ### Install SQL Server Named Instance Source: https://github.com/dsccommunity/sqlserverdsc/wiki/SqlSetup Installs a named instance of SQL Server, including the Database Engine and Analysis Services. Ensure prerequisites like .NET Framework 3.5 and 4.5 are installed first. The SQL Server setup runs under the SYSTEM account. ```powershell Configuration Example { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' -ModuleVersion '9.1.0' Import-DscResource -ModuleName 'SqlServerDsc' node localhost { #region Install prerequisites for SQL Server WindowsFeature 'NetFramework35' { Name = 'NET-Framework-Core' Source = '\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path. Ensure = 'Present' } WindowsFeature 'NetFramework45' { Name = 'NET-Framework-45-Core' Ensure = 'Present' } #endregion Install prerequisites for SQL Server #region Install SQL Server SqlSetup 'InstallNamedInstance-INST2016' { InstanceName = 'INST2016' Features = 'SQLENGINE,AS' SQLCollation = 'SQL_Latin1_General_CP1_CI_AS' SQLSvcAccount = $SqlServiceCredential AgtSvcAccount = $SqlAgentServiceCredential ASSvcAccount = $SqlServiceCredential SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' InstanceDir = 'C:\Program Files\Microsoft SQL Server' InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Backup' ASConfigDir = 'C:\MSOLAP13.INST2016\Config' ASDataDir = 'C:\MSOLAP13.INST2016\Data' ASLogDir = 'C:\MSOLAP13.INST2016\Log' ASBackupDir = 'C:\MSOLAP13.INST2016\Backup' ASTempDir = 'C:\MSOLAP13.INST2016\Temp' SourcePath = 'C:\InstallMedia\SQL2016RTM' UpdateEnabled = 'False' ForceReboot = $false BrowserSvcStartupType = 'Automatic' PsDscRunAsCredential = $SqlInstallCredential DependsOn = '[WindowsFeature]NetFramework35', '[WindowsFeature]NetFramework45' } #endregion Install SQL Server } } ``` -------------------------------- ### Install SQL Server Named Instance with DSC Source: https://github.com/dsccommunity/sqlserverdsc/wiki/SqlSetup Installs a named instance of SQL Server from a UNC path. Assumes SourceCredential has read permissions on the share and path. SQL Server setup runs under the SYSTEM account. ```powershell Configuration Example { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' -ModuleVersion '9.1.0' Import-DscResource -ModuleName 'SqlServerDsc' node localhost { #region Install prerequisites for SQL Server WindowsFeature 'NetFramework35' { Name = 'NET-Framework-Core' Source = '\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path. Ensure = 'Present' } WindowsFeature 'NetFramework45' { Name = 'NET-Framework-45-Core' Ensure = 'Present' } #endregion Install prerequisites for SQL Server #region Install SQL Server SqlSetup 'InstallNamedInstance-INST2016' { InstanceName = 'INST2016' Features = 'SQLENGINE,AS' SQLCollation = 'SQL_Latin1_General_CP1_CI_AS' SQLSvcAccount = $SqlServiceCredential AgtSvcAccount = $SqlAgentServiceCredential ASSvcAccount = $SqlServiceCredential SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' InstanceDir = 'C:\Program Files\Microsoft SQL Server' InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Data' SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.INST2016\MSSQL\Backup' ASConfigDir = 'C:\MSOLAP13.INST2016\Config' ASDataDir = 'C:\MSOLAP13.INST2016\Data' ASLogDir = 'C:\MSOLAP13.INST2016\Log' ASBackupDir = 'C:\MSOLAP13.INST2016\Backup' ASTempDir = 'C:\MSOLAP13.INST2016\Temp' SourcePath = '\fileserver.company.local\images$\SQL2016RTM' SourceCredential = $SqlInstallCredential UpdateEnabled = 'False' ForceReboot = $false BrowserSvcStartupType = 'Automatic' PsDscRunAsCredential = $SqlInstallCredential DependsOn = '[WindowsFeature]NetFramework35', '[WindowsFeature]NetFramework45' } #endregion Install SQL Server } } ``` -------------------------------- ### Retrieve SQL Server Setup Log from Custom Path Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Get‑SqlDscSetupLog Specify a custom installation path using the -Path parameter to retrieve the SQL Server setup log from a non-default location. ```powershell Get-SqlDscSetupLog -Path 'D:\SQLServer' ``` -------------------------------- ### Install SQL Server Default Instance with Analysis Services Source: https://github.com/dsccommunity/sqlserverdsc/wiki/SqlSetup Installs a default SQL Server instance and Analysis Services in Tabular mode. This configuration is for SQL Server 2016 or later. Ensure prerequisites like .NET Framework 3.5 and 4.5 are installed first. The SQL Server setup runs under the SYSTEM account, and provided credentials are not used for the installation itself. ```powershell Configuration Example { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' -ModuleVersion '9.1.0' Import-DscResource -ModuleName 'SqlServerDsc' node localhost { #region Install prerequisites for SQL Server WindowsFeature 'NetFramework35' { Name = 'NET-Framework-Core' Source = '\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path. Ensure = 'Present' } WindowsFeature 'NetFramework45' { Name = 'NET-Framework-45-Core' Ensure = 'Present' } #endregion Install prerequisites for SQL Server #region Install SQL Server SqlSetup 'InstallDefaultInstance' { InstanceName = 'MSSQLSERVER' Features = 'SQLENGINE,AS' SQLCollation = 'SQL_Latin1_General_CP1_CI_AS' SQLSvcAccount = $SqlServiceCredential AgtSvcAccount = $SqlAgentServiceCredential ASSvcAccount = $SqlServiceCredential SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' InstanceDir = 'C:\Program Files\Microsoft SQL Server' InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup' ASServerMode = 'TABULAR' ASConfigDir = 'C:\MSOLAP\Config' ASDataDir = 'C:\MSOLAP\Data' ASLogDir = 'C:\MSOLAP\Log' ASBackupDir = 'C:\MSOLAP\Backup' ASTempDir = 'C:\MSOLAP\Temp' SourcePath = 'C:\InstallMedia\SQL2016RTM' UpdateEnabled = 'False' ForceReboot = $false SqlTempdbFileCount = 4 SqlTempdbFileSize = 1024 SqlTempdbFileGrowth = 512 SqlTempdbLogFileSize = 128 SqlTempdbLogFileGrowth = 64 PsDscRunAsCredential = $SqlInstallCredential DependsOn = '[WindowsFeature]NetFramework35', '[WindowsFeature]NetFramework45' } #endregion Install SQL Server } } ``` -------------------------------- ### Install SQL Server Default Instance with Analysis Services Source: https://github.com/dsccommunity/sqlserverdsc/wiki/SqlSetup Installs a default instance of SQL Server and Analysis Services in Tabular mode. This configuration is for SQL Server 2022 or later. Ensure prerequisites like .NET Framework 3.5 and 4.5 are installed first. SQL Server setup runs under the SYSTEM account; provided credentials are not used for the installation itself. ```powershell Configuration Example { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlInstallCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAdministratorCredential = $SqlInstallCredential, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlServiceCredential, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $SqlAgentServiceCredential = $SqlServiceCredential ) Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' -ModuleVersion '9.1.0' Import-DscResource -ModuleName 'SqlServerDsc' node localhost { #region Install prerequisites for SQL Server WindowsFeature 'NetFramework35' { Name = 'NET-Framework-Core' Source = '\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path. Ensure = 'Present' } WindowsFeature 'NetFramework45' { Name = 'NET-Framework-45-Core' Ensure = 'Present' } #endregion Install prerequisites for SQL Server #region Install SQL Server SqlSetup 'InstallDefaultInstance' { InstanceName = 'MSSQLSERVER' Features = 'SQLENGINE,AS' SQLCollation = 'SQL_Latin1_General_CP1_CI_AS' SQLSvcAccount = $SqlServiceCredential AgtSvcAccount = $SqlAgentServiceCredential ASSvcAccount = $SqlServiceCredential SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName InstallSharedDir = 'C:\Program Files\Microsoft SQL Server' InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server' InstanceDir = 'C:\Program Files\Microsoft SQL Server' InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data' SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup' ASServerMode = 'TABULAR' ASConfigDir = 'C:\MSOLAP\Config' ASDataDir = 'C:\MSOLAP\Data' ASLogDir = 'C:\MSOLAP\Log' ASBackupDir = 'C:\MSOLAP\Backup' ASTempDir = 'C:\MSOLAP\Temp' SourcePath = 'C:\InstallMedia\SQL2016RTM' UpdateEnabled = 'False' ProductCoveredbySA = $true ForceReboot = $false SqlTempdbFileCount = 4 SqlTempdbFileSize = 1024 SqlTempdbFileGrowth = 512 SqlTempdbLogFileSize = 128 SqlTempdbLogFileGrowth = 64 PsDscRunAsCredential = $SqlInstallCredential DependsOn = '[WindowsFeature]NetFramework35', '[WindowsFeature]NetFramework45' } #endregion Install SQL Server } } ``` -------------------------------- ### Install SqlServerDsc Module Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Home Install the SqlServerDsc module from the PowerShell Gallery using PowerShellGet. This is the recommended method for getting started. ```powershell Install-Module -Name SqlServerDsc -Repository PSGallery ``` -------------------------------- ### Get Power BI Report Server Setup Configuration Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Deploy-Power-BI-Report-Server Retrieves detailed setup configuration information for the installed Power BI Report Server instance from the registry. Displays instance ID, installation folder, service name, and error dump directory. ```powershell $setupConfig = Get-SqlDscRSSetupConfiguration -InstanceName 'PBIRS' -ErrorAction 'Stop' Write-Information -MessageData "Instance ID: $($setupConfig.InstanceId)" -InformationAction 'Continue' Write-Information -MessageData "Install Folder: $($setupConfig.InstallFolder)" -InformationAction 'Continue' Write-Information -MessageData "Service Name: $($setupConfig.ServiceName)" -InformationAction 'Continue' Write-Information -MessageData "Error Dump Directory: $($setupConfig.ErrorDumpDirectory)" -InformationAction 'Continue' ``` -------------------------------- ### Get SQL Server Reporting Services Version Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Get‑SqlDscRSVersion Pipes the setup configuration object obtained from Get-SqlDscRSSetupConfiguration to Get-SqlDscRSVersion to retrieve the version of the SSRS instance. This example returns the version for the SSRS instance, such as '15.0.1100.0' for SQL 2019. ```powershell Get-SqlDscRSSetupConfiguration -InstanceName 'SSRS' | Get-SqlDscRSVersion ``` -------------------------------- ### Initialize SQL Server for Image-Based Deployment Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Initialize‑SqlDscImage Use this command to prepare the server for using the database engine for an instance named 'MyInstance'. Ensure the SQL Server installation media is available at the specified path. ```powershell Initialize-SqlDscImage -AcceptLicensingTerms -Features 'SQLENGINE' -InstanceId 'MyInstance' -MediaPath 'E:\' ``` -------------------------------- ### Install Power BI Report Server with Product Key Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscBIReportServer Install Power BI Report Server using a provided product key. This is useful for licensed installations. Remember to replace the placeholder product key with your actual key. ```powershell Install-SqlDscBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -ProductKey '12345-12345-12345-12345-12345' ``` -------------------------------- ### Create a SQL Database Source: https://github.com/dsccommunity/sqlserverdsc/wiki/SqlDatabase This example demonstrates creating a SQL database with a specified name and using PSDscRunAsCredential for authentication. ```powershell Configuration Example { param ( [Parameter(Mandatory = $true)] [System.Management.Automation.PSCredential] $SqlAdministratorCredential ) Import-DscResource -ModuleName 'SqlServerDsc' node localhost { SqlDatabase 'Create_Database' { Ensure = 'Present' ServerName = 'sqltest.company.local' InstanceName = 'DSC' Name = 'Contoso' PsDscRunAsCredential = $SqlAdministratorCredential } SqlDatabase 'Create_Database_with_different_collation' { Ensure = 'Present' ServerName = 'sqltest.company.local' InstanceName = 'DSC' Name = 'AdventureWorks' Collation = 'SQL_Latin1_General_Pref_CP850_CI_AS' PsDscRunAsCredential = $SqlAdministratorCredential } SqlDatabase 'Create_Database_with_different_compatibility_level' { Ensure = 'Present' ServerName = 'sqltest.company.local' InstanceName = 'DSC' Name = 'Fabrikam' CompatibilityLevel = 'Version130' PsDscRunAsCredential = $SqlAdministratorCredential } SqlDatabase 'Create_Database_with_different_recovery_model' { Ensure = 'Present' ServerName = 'sqltest.company.local' InstanceName = 'DSC' Name = 'FabrikamData' RecoveryModel = 'Simple' PsDscRunAsCredential = $SqlAdministratorCredential } SqlDatabase 'Create_Database_with_specific_owner' { Ensure = 'Present' ServerName = 'sqltest.company.local' InstanceName = 'DSC' Name = 'FabrikamDataOwner' OwnerName = 'sa' PsDscRunAsCredential = $SqlAdministratorCredential } } } ``` -------------------------------- ### Example 3: SqlScript Configuration Source: https://github.com/dsccommunity/sqlserverdsc/wiki/SqlScript This example demonstrates a basic SqlScript configuration, including setting database name, query timeout, and run-as credentials. ```powershell Variable = @( ('DatabaseName={0}' -f $Node.DatabaseName) ) QueryTimeout = 30 PsDscRunAsCredential = $SqlAdministratorCredential } } } ``` -------------------------------- ### Get Config File via Setup Configuration Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Get‑SqlDscRSConfigFile Retrieves the setup configuration for SSRS and pipes it to Get-SqlDscRSConfigFile to retrieve the configuration file as XML. This method is useful when you already have the setup configuration object. ```powershell Get-SqlDscRSSetupConfiguration -InstanceName 'SSRS' | Get-SqlDscRSConfigFile ``` -------------------------------- ### Install Power BI Report Server with Product Key Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscPowerBIReportServer Installs Power BI Report Server and specifies a product key for activation. The license terms must be accepted. ```powershell Install-SqlDscPowerBIReportServer -AcceptLicensingTerms -MediaPath 'E:\PowerBIReportServer.exe' -ProductKey '12345-12345-12345-12345-12345' ``` -------------------------------- ### Install SQL Server using a configuration file Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install-SqlDscServer Installs SQL Server using the specified configuration file. This method is suitable for automated and repeatable installations. ```APIDOC ## Install-SqlDscServer -ConfigurationFile ### Description Installs SQL Server using the configuration file 'MySqlConfig.ini'. This allows for a declarative and repeatable installation process. ### Method Install-SqlDscServer ### Parameters #### Path Parameters - **ConfigurationFile** (string) - Required - The path to the configuration file (e.g., 'MySqlConfig.ini') that contains the installation settings. - **MediaPath** (string) - Required - The path to the SQL Server installation media. ### Request Example ```powershell Install-SqlDscServer -ConfigurationFile 'MySqlConfig.ini' -MediaPath 'E:\' ``` ``` -------------------------------- ### Get Report Server Installations via Pipeline Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Get‑SqlDscRSDatabaseInstallation Use this command to retrieve all report server installations registered in the database by piping the output of `Get-SqlDscRSConfiguration` to `Get-SqlDscRSDatabaseInstallation`. ```powershell Get-SqlDscRSConfiguration -InstanceName 'SSRS' | Get-SqlDscRSDatabaseInstallation ``` -------------------------------- ### Install SSRS with Default Settings Source: https://github.com/dsccommunity/sqlserverdsc/wiki/Install‑SqlDscReportingService Use this command to perform a basic installation of SQL Server Reporting Services. Ensure the MediaPath points to the correct executable. ```powershell Install-SqlDscReportingService -AcceptLicensingTerms -MediaPath 'E:\SQLServerReportingServices.exe' ```