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  

$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}

                Write-Host "already exists!"

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


figured it out:





$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.