For instance, last week I was working with two instances that contained databases part of an Always On availability group and needed to ensure that all databases on the primary were on the secondary.
Now I know there’s a few ways to do this but I needed a quick and easy method as there were over 300 dbs involved.
The method I used to do this implemented the powershell cmdlet Compare-Object
What this does is pretty much what it says on the tin. The cmdlet takes two objects and compares them based on a input property (in this case it’ll be database name).
This can turn into a much more complicated comparison, but Andrew shows that the basic concept is quite straightforward.