I am trying to build a config file for a monitoring app for all our SQL Servers. For this I need to add all instance details of a server in a config file(i.e. one file will be generated per server and not instance). So even if server has multiple instances, it will only have one config file with its details of all instances mentioned in it. For a server with only single instance it is not a problem. What I need help is on a server with multiple instances. For e.g. If server1 has two instances Instance1 and 2 then config file should look like below and exported to a text file. Likewise for a single instance server there will be only 1 line without comma at the end and exported to a text file.
"Server=Server1Instance1;Port=50001;User ID:sqltest;password:****", "Server=Server1Instance2;Port=50002;User ID:sqltest;password:****"
I am getting all server instance details from a SQL Server database stored in format ServerName, InstanceName, PortName. Could someone please guide me how do I achieve it using Powershell? Thanks!
Go to Source