Answer the question
In order to leave comments, you need to log in
How to output values from an array without curly braces in Powershell?
Hello.
There is a script that displays the names of the containers in the organizational unit.
$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}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question