Как вывести значения из массива без фигурных скобок в Powershell?

Всем привет.

Есть скрипт, который отображает имена контейнеров в организационном подразделении.

spoiler

$ounit = Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase "OU=example,DC=example,DC=local" -SearchScope Subtree | Where {
    $_.Name -notlike "Bank" -and 
    $_.Name -notlike "aux" -and
    $_.Name -notlike "SharePoint" -and
    $_.Name -notlike "disabled" -and
    $_.Name -notlike "old" -and
    $_.Name -notlike "operc" -and
    $_.Name -notlike "External" -and
    $_.Name -notlike "Scan" -and
    $_.Name -notlike "dad" 
} | select Name | sort Name


for ($i = 0; $i -lt $ounit.Count; $i++) {
    $a = "$i {0}" -f $ounit[$i]
    $a
}

$ar = Read-Host "Enter"

for ($i = 0; $i -lt $ounit.Count; $i++) {
    $a = "$i {0}" -f $ounit[$i]
    if ($ar -match $i) {
        $r = $ounit[$i] 
    }
}

$r.Name



Отлично работает, как надо, но выводит данные

0 @{Name=Administration}

Как избавиться от фигурных скобок, чтобы выводилось 0 Administration?
  • Вопрос задан
  • 96 просмотров
Решения вопроса 1
@AAT666
for ($i = 0; $i -lt $ounit.Count; $i++) {
    $a = "$i {0}" -f $ounit[$i].Name
    $a
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы