Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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