Here is a PowerShell script to find the SQL server instance and store the value in a variable:

 
$InstanceName = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server").InstalledInstances
$Instance = $env:computername+'\'+$InstanceName

Write-Host "The SQl Server instance name is $Instance"

Categories:

Comments are closed