Powershel输出-加入逗号

时间:2019-03-13 13:23:47

标签: powershell scripting

您好,我有一个密码可以打印特定组的成员。但是输出确实让我满意。

到目前为止,我的代码:

$ADGroup = Get-ADGroup $Id -Properties member | Select-Object -ExpandProperty member
                    Write-Output "`n" | Out-File $Log -append



                    $UserList += Write-Output "Member of $Id :
                    "
                    foreach ($Object in $ADGroup)
                        {
                            $Group      = Get-ADUser -filter * -SearchBase "$Object"
                            if($Group -ne $null)
                                {
                                    $GrName     = $Group.samaccountname
                                    $UserList += $GrName
                                }


                        }

我像这样出没了

的成员

名称1

name2

等...

但我希望它成为name1,name2

1 个答案:

答案 0 :(得分:0)

好的,我自己解决了。

只需将", "添加到$UserList += $GrName