.PARAMETER Path
Specifies the path to a SQL script file holding sp_configure queries for each of the settings to be changed. Export-DbaSPConfigure creates a suitable file as its output.

.PARAMETER Force
If this switch is enabled, no version check between Source and Destination is performed. By default, the major and minor versions of Source and Destination must match when copying sp_configure settings.

.PARAMETER EnableException
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

.PARAMETER WhatIf
If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

.PARAMETER Confirm
If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

Imports the sp_configure settings from the source server sqlserver and sets them on the sqlcluster server using the SQL credentials stored in the variables $SourceSqlCredential and $DestinationSqlCredential

if(!(Test-SqlSa-SqlInstance$sourceserver-SqlCredential$SourceSqlCredential)){Stop-Function-Message"Not a sysadmin on $sourceserver. Quitting."-CategoryPermissionDenied-ErrorRecord$_-Target$server-Continue}

if(!(Test-SqlSa-SqlInstance$destserver-SqlCredential$DestinationSqlCredential)){Stop-Function-Message"Not a sysadmin on $destserver. Quitting."-CategoryPermissionDenied-ErrorRecord$_-Target$server-Continue}

if($sourceserver.versionMajor-ne$destserver.versionMajor-and$force-eq$false){Write-Message-LevelWarning-Message"Source SQL Server major version and Destination SQL Server major version must match for sp_configure migration. Use -Force to override this precaution or check the exported sql file, $sqlfilename, and run manually."return}

$destprop=$destprops|where-object{$_.Displayname-eq$displayname}if($null-ne$destprop){try{$destprop.configvalue=$sourceprop.configvalue$null=$destserver.Query("RECONFIGURE WITH OVERRIDE")Write-Message-LevelOutput-Message"updated $($destprop.displayname) to $($sourceprop.configvalue)."}catch{Stop-Function-Message"Could not set $($destprop.displayname) to $($sourceprop.configvalue). Feature may not be supported."-ErrorRecord$_-Continue}}}try{$destserver.Configuration.Alter()}catch{$needsrestart=$true}

if($needsrestart-eq$true){Write-Message-LevelWarning-Message"Some configuration options will be updated once SQL Server is restarted."}else{Write-Message-LevelOutput-Message"Configuration option has been updated."}}

}else{if($Pscmdlet.ShouldProcess($destination,"Importing sp_configure from $Path")){$server.Configuration.ShowAdvancedOptions.ConfigValue=$true$sql=Get-Content$Pathforeach($linein$sql){try{$null=$server.Query($line)Write-Message-LevelOutput-Message"Successfully executed $line."}catch{Stop-Function-Message"$line failed. Feature may not be supported."-ErrorRecord$_-Continue}}$server.Configuration.ShowAdvancedOptions.ConfigValue=$falseWrite-Message-LevelWarning-Message"Some configuration options will be updated once SQL Server is restarted."}}}end{if($Path.length-gt0){$server.ConnectionContext.Disconnect()}else{$sourceserver.ConnectionContext.Disconnect()$destserver.ConnectionContext.Disconnect()}