这最终成为我完成最终目标的最终编码。我要感谢我使用的所有海报,从你们所有人那里学到了我想要的解决方案。
$EmployeeLists = @()
$ManagerLists = @()
$Employees = @()
$Managers = @()
$CSVFiles = Import-CSV "C:\T2\EmployeeManager.csv"
ForEach($CSVFile in $CSVFiles)
{
$EmployeeLists += ($CSVFile.Employee)
}
ForEach($CSVFile in $CSVFiles)
{
$ManagerLists += ($CSVFile.Manager)
}
$Employees += ForEach ($EmployeeList in $EmployeeLists) { Get-ADUser -Properties * -Filter { DisplayName -like $EmployeeList } | Select SamAccountName -ExpandProperty SamAccountName }
$Managers += ForEach ($ManagerList in $ManagerLists) { Get-ADUser -Properties * -Filter { DisplayName -like $ManagerList } | Select SamAccountName -ExpandProperty SamAccountName }
$EmployeeLists
"`n`n`n"
$Employees