We need a PowerShell Wrapper. Let me explain. Note: I do not know PowerShell at all. I have been searching on the web but I am confusing myself with all the information.
We have 5 Idera Databases on 5 different SQL Server instances. We need to log onto each instance and search where the Instance is registered on. The Instance we are interested in would be passed into the query to determine if the instance is listed in the database.
We are using Ansible to run the job.
Once you log onto the Idera Database SQLdmRepository in PowerShell from Ansible (which I don't know how is done) you can run the following TSQL query to see if it exists
DECLARE @InstanceName VARCHAR(500)
SET @InstanceName = 'abcdeppxx0018\prod01' - This needs to be passed
SELECT *
FROM [SQLdmRepository].[dbo].[MonitoredSQLServers] WHERE Active =1 AND [InstanceName] = @InstanceName
If it does not exist then the output is NULL or no rows. If it does exist, then one row should output. However, this will need to be done on each of the 5 Idera Database servers (thus looping through the 5). Thus, the Idera Database Instance that has a row needs to be outputted to the PowerShell script and the looping can stop.
All the Idera Databases SQLdmRepository are on the following instances:
usctappxx0271\prod01
usctappxx0208\prod01
usctappxx0209\prod01
usctappxx0210\prod01
usctappxx0211\prod01
Is there any generic script out there that someone can point me to so that I can get started?
Laura