Answer the question
In order to leave comments, you need to log in
How to populate the Division field based on the SAMAccountName from the list?
There is a list (example below) containing the SAMAccountName of the users and a value that needs to be entered in the Division field in Active Directory. I don't know how to correctly create a loop that will match the SAMAccountName from the list with the desired user in Active Directory and enter the value in the Division field
SAMAccountName Group
derek.aik OPS
sandy.bruks BON
alex.gone GET
sten.ports OPS
abby.kaily ROAD
Answer the question
In order to leave comments, you need to log in
There are two main types of object loops in ps:
#классический цикл
foreach ($obj in $list) {
# сделать что-нибудь с переменной $obj
Set-something -name $obj.name -value $obj.value
}
#цикл с использованием pipeline
$list | foreach-object {
# сделать что-нибудь с переменной $_
Set-something -name $_.name -value $_.value
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question