So I have performed some major customization on SQLSPADE thats available on CodePlex
sqlspade.codeplex.com
Here is where I am stuck. I have 2 functions in play. When the first functions executes, It calls the second function called Install-SQLSERVER. The code Snippet for the first function is provided below.
Function Fn_Install() { $Global:ResultTextBox.AppendText(" Installaling $Global:Version $Global:edition Edition on $env:computername .Please Wait....`n ") Install-SQLSERVER -Parameters $ht -TemplateOverrides $overrides -Verbose -DontCopyLocal -InstallOnly Return }
As you can see, it writes data to a text box and calls the function Install-SQLSERVER. Within that function, it runs the setup.exe to run a silent SQL Server installation.The code snippet for the second function is provided below
if (($InstallOnly -eq $true -or $Full -eq $true) -and $Global:CriticalError -eq $false) { Write-Log -level "Section" -message "Starting SQL Server Install" #Call the queit install process - because it writes to the console we don't have to force the code to wait if ($pscmdlet.ShouldProcess("Start SQL Installer Package", "Install SQL")) #if (!$Global:Simulation) { Invoke-Expression $command [int] $Global:exitCode = $Lastexitcode } if ($Global:exitCode -eq 0) { $Global:ResultTextBox.AppendText(" Installation Completed Successfully `n ") $Global:ButtonPostInstall.enabled = $True $Global:CriticalError = $false } else { Write-Log -level "Error" -message "SQL Server Install failed - please check the console output" $Global:ResultTextBox.AppendText(" Installation Failed with error Code: $exitCode `n ") $Global:CriticalError = $true } else { Write-Log -level "Section" -message "Skipping SQL Server Install" }
So I am evaluating the condition based on $lastexitcode. It evaluates the condition and does what its supposed to when the installation fails with a non-zero error code. However, when the installation succeeds, it doesnt evaluate the IF condition at all and just stays stuck on the screen. I have to kill the script from the task manager when that happens. The problem is, I cant evaluate if the $lastexitcode was 0 since I have to kill the entire session. Any idea why this is happening?
Thanks,
Lokesh
Lokesh Gunjugnur