PowerShell Script\Wrapper

LauraC 21 Reputation points
2022-10-03T17:46:39.367+00:00

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

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,361 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 44,776 Reputation points
    2022-10-03T18:21:01.513+00:00

    Isn't Idera just a productivity tools supplier? What software are you using for your database backend? MSSQL? MySQL? Oracle? Azure?

    If it's MSSQL or Azure, then you might only have to use the cmdlets in the SQL Server PowerShell Module (sql-server-powershell

    0 comments No comments

  2. LauraC 21 Reputation points
    2022-10-03T18:46:22.38+00:00

    We are using PowerShell to log onto the SQL Server Instance, to run the Query passing the instance that we are interested in, and to return if the instance is listed in the table.