0
ADから情報を取得しようとしています。いくつかのセキュリティグループに対して、group_name、emplyeeid、name、およびsammacountの4つの列を持つcsvが必要です。 グループメンバーと名前を取得する最初のものがあります。 Get-ADGroup -Filter {Name-like "security_group *"} | foreachの{$グループ=PSから情報を取得するPS: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
、私に社員、名前を取得し、別の1、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にコピーできるので、これは大丈夫です。 私はこのすべてを1つのスクリプトに入れて4つすべての列を与えようとしましたが、正しいとは思えません。どんな助けもありがとう!