Last active
April 27, 2018 22:23
-
-
Save R41D3NN/2f83d5ded6ae8eb597fef580d94416ee to your computer and use it in GitHub Desktop.
Secret Server report to show discovered total AD users per group.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
B.[Group], | |
COUNT(B.[AccountName]) AS [Total Members] | |
FROM ( | |
SELECT | |
Split.a.value('.', 'VARCHAR(1000)') AS [Group], | |
A.[AccountName] | |
FROM ( | |
SELECT | |
[ca].[AccountName], | |
CAST ('<M>' + REPLACE(REPLACE(REPLACE(REPLACE([ca].[SearchGroups], '&', '\u0026'), '<', '\u003C'), '>', '\u003E'), CHAR(59), '</M><M>') + '</M>' AS XML) AS [Group] | |
FROM [tbComputerAccount] [ca] | |
JOIN [tbOrganizationUnit] [ou] ON [ca].[OrganizationUnitId] = [ou].[OrganizationUnitId] | |
) AS A | |
CROSS APPLY [Group].nodes ('/M') AS Split(a) | |
) B | |
GROUP BY | |
[Group] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment