0
我想從AD獲取一些信息。我需要一個帶有4列的csv:多個安全組的group_name,emplyeeid,名稱和sammacount名稱。 我有第一個讓我成爲組的成員和名稱: Get-ADGroup -Filter {名字般的「security_group *」} |的foreach {$組=PS從AD獲取信息:group_name,employeeid,name,samacoountname
$_.Name; Get-ADGroupMember $group | select @{N='group'; E={$group}},Name} | select group,Name| Export-CSV -Path C:\temp\test.csv
而另外一個讓我的僱員,姓名,samacoountname:
Get-ADGroup -filter {Name -like "group_name*"} |
foreach {
Write-Host "Exporting $($_.name)"
$name = $_.name -replace " ","-"
$file = Join-Path -path "C:\temp\test" -ChildPath "$name.csv"
Get-ADGroupMember -Identity $_.distinguishedname -Recursive |
Get-ADObject -Properties SamAccountname,employeeid |
Select employeeid,Name,SamAccountName |
Export-Csv -Path $file -NoTypeInformation
}
這讓我對每個組不同的CSV文件。沒關係,因爲我可以將所有文件複製到同一個csv中。 我試圖把所有這一切都放到一個腳本中,給我所有4個colums,但我似乎無法正確地做到這一點。任何幫助,將不勝感激!