powershell - How to verify successful installation of SQL Server 2008 R2 -


i'm trying install sql server 2008 r2 silently using powershell script. after installation need verify installation successful. there way check exit code in sqlsetup.log file successful installation?

following code, i'm using:-

# read current directory $scriptpath = $myinvocation.mycommand.path $parentdir = split-path $scriptpath  #read config file current directory $configfile = $parentdir + '\configurationfile.ini' write-host $configfile #holds base setup current directory $setupfile=$parentdir + '\setup.exe' write-host $setupfile $sp3setupfile=$parentdir + '\sqlserver2008r2_sp3\setup.exe' write-host $sp3setupfile  #start of log file $start="========================================================================================" $start | out-file $env:temp\installsql2008r2_log.txt -append  #printsd current date , time in log file $date=get-date $date | out-file $env:temp\installsql2008r2_log.txt -append  #starting sql base installation $installbasesql="installing sql server 2008 r2" $installbasesql | out-file $env:temp\installsql2008r2_log.txt -append  #installs sql server 2008 r2 standard edition  & "$setupfile" /configurationfile="$configfile"  #checks whether installed  $existstring = select-string -path "$env:temp\sqlsetup*.log" -pattern "setup closed exit code: 0x00000000" if($existstring)       {           $successstatus = "installation of sql server 2008 r2 completed"         $successstatus | out-file $env:temp\installsql2008r2_log.txt -append         #write-host "installation of sql server 2008 r2 completed"         #out-file $env:temp\installsql2008r2_log.txt -append           # $log.name | out-file $c:\filecontainingstring.txt -append       }       else       {           $failstatus = "installation couldn't complete, more details please check sqlsetup.txt in temp folder"         $failstatus | out-file $env:temp\installsql2008r2_log.txt -append      }  #installing sql patch $installsqlsp3="installing sql server 2008 r2 sp3" $installsqlsp3 | out-file $env:temp\installsql2008r2_log.txt -append  #install sql server 2008 r2 sp3 patch & "$sp3setupfile" /instancename=mssqlserver /quiet  #completion message $patchcomplete="installation of sql server 2008 r2 sp3 completed3" $patchcomplete | out-file $env:temp\installsql2008r2_log.txt -append   $end="========================================================================================" $end | out-file $env:temp\installsql2008r2_log.txt -append 

if ((get-content "$env:temp\sqlsetup*.log" -encoding unicode)[-2] -like "*0x00000000") {     ## installed } 

checking log errors may not 100%, may want check hklm:\software\microsoft\microsoft sql server\100\bootstrap release\1033\currentversion\version or too.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -