(Get-ItemProperty -Path ‘Registry::HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server’ )
this works and shows all the ps attributes but I need to add the below as I need the instance names as I am trying to retrieve them for the bit code
-Name InstalledInstances).InstalledInstances
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
I don’t get it. You’ve been asking about how to get a property value from a registry key, and most recently store it in a variable called $sqlinstances.
But you say that’s not returning anything for you, when others have tested and at least in our instances it works. Then you say “how I got the list” but the code you provided doesn’t look at the registry it pulls the Services on the machine you run the code on.
What exactly are you trying to accomplish in total because we’ve already provided the correct syntax for your original question.
I always got the Instance name using the provider, because I find it more reliable than the registry.
I do not need to know the version number or anything ahead of time.
You can keep recusrsing from there and do just about anything you would want to do in SQL using the provider. It is slower but more powerfull in my mind.
Note: that you have to set location in SQL you can not do recursive Get-ChildItem queries. You have to be in the location and then run Get-ChildItem. If there are no databases you will get an error there. Also if you are not a member of builtin\admins you will nto be able to see the databases.