0

Can anyone explain me why the command Test-SqlAvailabilityGroup takes too much time ? Is there a fastest way to check if a an availability group exists or not (preferably on PowerShell) ? Thanks.

4
  • Are you noticing this slowness with a specific version of SQL Server? Nov 16 '20 at 14:55
  • I'm currently testing it on SQL Server 2016 staging environment. I'll try to test it on our production environment and let you know asap.
    – KhalilG
    Nov 16 '20 at 15:05
  • @JoshDarnell it took about 4 minutes to complete on our production env. This is particularly annoying for script testing.
    – KhalilG
    Nov 17 '20 at 8:20
  • It can be slow if replicas are remote. Try to run it locally on the machine itself Nov 17 '20 at 15:28
0

I guess if you only want to see if the Availability group exists, you could query the DMV:

select name from sys.availability_groups

That will return all the name of the AG(s) on that specific instance.

It could be done from PowerShell too with a "invoke-sqlcmd" pretty easilly.

0

Test-SqlAvailabilityGroup evaluates health of your AG, which may take some time depending upon multiple factors. If you just want to check if AlwaysOn is enabled or not, you can use this

(Get-SqlInstance -ServerInstance 'Myserver').IsHadrEnabled

If above returns 'True', then use below to get list of Availability groups on host

Get-SqlInstance -ServerInstance 'MyServer' | Select AvailabilityGroups

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.