有人可以说我的代码有什么问题吗?
$csvimport = Import-Csv $csvfile -Delimiter ';'
$csvimport | ForEach-Object {
foreach ($property in $_.PSObject.Properties) {
if ($property.Name -contains "Vorname") {
$vorname = $property.Value
} else {
$nachname = $property.Value
}
$user = Get-ADUser -Server $ADServer -Credential $GetAdminact -LDAPFilter (&(GivenName=$vorname)(Sn=$nachname)) -SearchBase $SearchBaseG
$user |
Select-Object @{Label = "Vorname";Expression = {$_.GivenName}},
@{Label = "Nachname";Expression = {$_.Surname}},
@{Label = "Telefon";Expression = {$_.telephoneNumber}} |
Export-Csv -Path $csvfiles -NoTypeInformation
}
}
我只是想从CSV导入名称/姓氏。然后在Active Directory中搜索用户,并使用他们的电话号码生成一个新的CSV。