-1
私は成功しないで複数の配列でforeachループを実行しようとしています。 ログインしているコンピュータのローカル管理者としてリストからユーザーを追加して、psexecを起動します。 プロパティCustomComputernameは、ユーザーがログオンしているComputernameを表すextensionAttributeです。Powershell Foreach複数の配列
$array1= get-content "C:\list.txt"
$array2= foreach ($u in $array1)
{get-aduser -filter {samaccountname -eq $user} -Properties CustomComputername |
Select -expandproperty CustomComputername}
foreach ($Computer in $array2){
foreach ($u in $array 1) {
Invoke-PsExec -ComputerName $Computer -Command "net localgroup administrators $u /add"
}
上記のコマンドはすべてのユーザーをすべてのコンピュータに追加します。 ログインしている1台のコンピュータに1人のユーザーを追加するにはどうすればよいですか? 私はそれが働くことができない、私はまだ学んでいると私は十分な知識がありません。どんな助けもありがとうございます。前もって感謝します!