Get-SQLInstance

This function looks up SQL Instance information via the registry on local and remote systems. Information looked up is Version, Edition type, whether the SQL Instance is part of a cluster and the other nodes in the cluster and the full name that can be used in another script to

 
 
 
 
 
4.7 Star
(19)
18,499 times
Add to favorites
Databases
6/7/2016
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • SQLCluster
    1 Posts | Last post May 14, 2018
    • Cluster Detection does not work with a SQLCluster that is a named Instance. I have an Standard Instance named "SQL01"(what is the computername)not clustered and a named Instance called "Inst01" that is clustered. The Report shows for SQL01 "not clustered" , what is correct!! For Instance "sqlcluster\inst01" it shows "not clustered" what is not correct
  • cmdletbinding error
    1 Posts | Last post March 07, 2018
    • Hi,
      
      I got the following error: 
      
      +     [cmdletbinding()]Â
      +     ~~~~~~~~~~~~~~~~~
      Unexpected attribute 'cmdletbinding'.
      
      I've run the cmdlet many times before. After I updated my SQL Server module, this started happening. Anyone else see this issue? 
      
      Thanks in advance!
      
      ~ Harry
  • incorrect version returned
    1 Posts | Last post January 22, 2018
    • Hi,
      
      Th script works almost fine, i've tried i against several SQL servers and I've got the same problem.
      
      I've got a management Computer With SQl Management studio installed and when i look at my main SQL server, it reports 13.0.4001.0.
      
      When I run the script against the same server and it returns Version           : 13.1.4001.0.
      
      Searched the web for 13.1.xxxxx version but could not find any information.  Just a reference on this page  https://sqlserverbuilds.blogspot.be
      
      
  • Getting error on some default instances
    1 Posts | Last post December 20, 2017
    • Hi, on some of my servers, I am getting this error when trying to view properties for the default instance (MSSQLSERVER) :
      The 'fullname' property looks like this: servername\System.Object[]
      And the error is this:
      
      You cannot call a method on a null-valued expression.
      At line:225 char:25
      + ...             $PropertyHash['Version'] = $instanceRegSetup.GetValue('Ve ...
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull
      
  • multi-instance bug
    1 Posts | Last post May 04, 2017
    • Thanks for a great script Boe. Is this function built into the SqlServer module on git hub now too? I have been testing the script out and found that when there are multiple instances (named SQL2014, SQL2016 in my case) several bugs occur are triggered.
      
      line 177 does first 1, which in my case returns the SSAS msmdsrv.exe executable file instead of DB engine sqlserv.exe which means the regex logic doesn't work and the script tries to check the file version of the wrong or non-existent file. 
      
      line 200 incorrectly overwrites a valid value for $PropertyHash['Instance'] of "SQL2014" with an array of all instances {MSSQL$SQL2014, MSSQL$SQL2016}. Is $PropertyHash['Instance']. I think this is the same issue VooDewd posted on August 03, 2016.
      
      line 215 $PropertyHash[$Name] = $Data then assigns a valid value for one of the WMI results returned but the WMI propertyIndex isn't correlated with the instance that is being constructed in $propertyHash so it overwrites $propertyhash with the values for all instances and the last instance returned by WMI is retained. In my case SQL2016 instance settings overwrite the $propertyHash values for SQL2014 as WMI returns that instance last. if $WMIParams.Query is changed to SELECT * FROM SqlServiceAdvancedProperty WHERE servicename = MSSQL$SQL2014 ($InstanceValue) that should fix it.
      
  • Any plans to include the detection of SSAS, SSRS of SSIS instances?
    1 Posts | Last post December 13, 2016
    • Any plans to detect installed instances of Intergration Servcices, Analysis Services or Reporting Services?
  • Error
    1 Posts | Last post October 20, 2016
    • I get the following error when i run Get-SQLInstance -Computername SRVR01
      
      Unable to find type [ordered]: make sure that the assembly containing this type is loaded.
      At C:\Users\xyz\Desktop\Get-SQLInstance.ps1:80 char:38
      +             $PropertyHash = [ordered] <<<< @{
          + CategoryInfo          : InvalidOperation: (ordered:String) [], RuntimeException
          + FullyQualifiedErrorId : TypeNotFound
      
      Any ideas? Thanks! 
  • Returning similar information for separate instances
    1 Posts | Last post August 03, 2016
    • When run against a 2012 node hosting multiple (3) instances, the Instance property shows the separate instance names; however all other properties (Installpath, Datapath, Vsname, Regroot, Instanceid, Startupparameters) which should have specific values per instance, are all showing the same values of just one specific instance.
      
      Thank you in advance for this script!
      
  • Unable to find get-sqlinstance
    2 Posts | Last post June 20, 2016
    • When I am running the script its says the below error.
      
      The term 'Get-SQLInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
       the spelling of the name, or if a path was included, verify that the path is correct and try again.
      At D:\Get-SQLInstance.ps1:1 char:16
      + Get-SQLInstance <<<<  -ComputerName $Computernames -Verbose | ForEach {
          + CategoryInfo          : ObjectNotFound: (Get-SQLInstance:String) [], CommandNotFoundException
          + FullyQualifiedErrorId : CommandNotFoundException
      
      Kindly Help me
    • You need to first create the function in Powershell. Simply run the downloaded .ps1 file in an elevated PS session, and then try running Get-SQLInstance.
      As an alternative, you can put the function in your powershell profile, so that you can use it often, without needing to create it everytime.
  • Services -match
    3 Posts | Last post June 13, 2016
    • Awesome job on this Boe! But of course,  I managed to find a edge case "Bug", one of my servers has a service that also matches the instance name, and it checks the file version of of that binary instead of the sqlservr.exe. I'm stumped as to a fix right now, but I think tonight I'll dig around and see if I can come up with something.
    • there's probably a better way, but adjusting this line fixes it in my instance:
      
      $serviceKey = $servicesReg.GetSubKeyNames() | Where {
      ($_ -match "$instance") -and ($_ -match "MSSQL")
      } | Select -First 1
      
      Does the SQL Server Service always start with MSSQL$<instancename> ?
    • Thanks! I've updated the code to include this.
1 - 10 of 19 Items