A fairly basic script - searches Ou in AD and exports computers - I want to store each computer into an array so I can loop through later and run some commands against the computers. Although not having much luck with the array itself - am I completely off the track here?
$computers = @()
$i = 0
$ou = [ADSI]"LDAP://OU=Domain Controllers,DC=test,DC=local"
foreach ($child in $ou.psbase.Children) {
if ($child.ObjectCategory -like '*computer*') {
Write-Host $child.Name
$computers[$i] = $child.name
}
$i += 1
}