I have a powershell script to enumerate the members of SQL Server role members using powershell. I have this script

<... cut the connection details for brevity, 
$SqlInstance is a Microsoft.SqlServer.Management.Smo.Server object ...>

$db = $SqlInstance.Databases[$Database]

foreach ($role in $db.Roles)
{
    foreach ($memberlist in $role.EnumMembers)
    {
        foreach ($member in $memberlist)
        {
            Write-Host ($member)
        }       
    }
}

I get output like this:

System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()
System.Collections.Specialized.StringCollection EnumMembers()

How do I actually see the role members? Confused.

link|improve this question

feedback

1 Answer

Worked it out I needed () on the end of EnumMembers, DOH!

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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