0

我可能无法很好地解释这一点,所以我将从结果开始,该结果将是经理姓名的 excel 以及他们所属的所有组以及类别、范围和电子邮件。我能够获得直接报告并将他们所在的所有组导出到 txt。我尝试使用该 .txt 文件来遍历并从每个组中获取我需要的每个属性。那是我坚持的部分。

 Function Get-DirectReport {
[CmdletBinding()]
    param(
        [Parameter(
            Mandatory = $false,
            ValueFromPipeline = $true,
            ValueFromPipelineByPropertyName = $true
        )][string]  $SamAccountName,
 
        [switch]  $NoRecurse
    )
 
    BEGIN {}
 
    PROCESS {
        $UserAccount = Get-ADUser $SamAccountName -Properties DirectReports, DisplayName
        $UserAccount | select -ExpandProperty DirectReports | ForEach-Object {
            $User = Get-ADUser $_ -Properties DirectReports
            if ($null -ne $User.EmployeeID) {
                if (-not $NoRecurse) {
                    Get-DirectReport $User.DirectReports
                }
                [PSCustomObject]@{
                    DirectReports     = $User.DirectReports
                                     
                }
            }
        }
    }
 
    END {}
 
}
4

0 回答 0