Why is powershell appending a random 0?

I wrote a script that adds roles/members to a database/cube.

for some reason, everytime a role/member is added, a 0 is outputted on the console. Where is that coming from?? I am starting to suspect that the Analysis.Role property has a default 0 output, because when my if statement runs and the member already exists, so no role/member is added, no 0 is outputted. only when a role doesnt exist a 0 is outputted because its adding the role. so thats how i narrowed it down to that conclusion.

But if so, how can i suppress this “0”?

$ErrorActionPreference = 'silentlycontinue' # suppress all exceptions

$as = New-Object Microsoft.AnalysisServices.Server  
$as.connect("$server")

$db = $Analysis_Server.Databases.FindByName($CUBE)

$ROLE = $db.Roles.FindByName($CUBE_ROLE)
$member = "member1"

$memberExists = $false

if ($ROLE) # if role exists already...check if group exists, or just add group
{
$memberExists = $ROLE.Members.GetEnumerator() | ?{$_.name -like $member} | select -First 1 | %{$True}

            if($memberExists)
            { 
                Write-Host "already exists!"
            }
            else
            {
                $ROLE.Members.Add($member)
                $ROLE.Update()
            }

            $error.clear()
            if ($error[0])
            {
                Write-Host ("`r`nError Adding Group!" + "$($error[0])`r`n")
            }
        }

zero

figured it out:

 

Change:

$ROLE.Members.Add($member)

to:

$ROLE.Members.Add($member) | Out-Null

If you add an object to an array using .Add(), its current index (0 in this case) will be returned.