Trying to export a list of expiring user accounts from Active Directory, and specifically their managers' name RRS feed

  • Question

  • I don't have much PS scripting experience, but have spent some time searching for an answer.  I can easily extract the expiring accounts, but am struggling with adding the name of the manager to the output.  Any help is greatly appreciated.  Below is a snippet from the script: (the bold is where I am attempting to find the correct syntax)

    • $adUser = Search-ADAccount -AccountExpiring -TimeSpan 6.00:00:00 | Select-Object Name,AccountExpirationDate | Sort-Object AccountExpirationDate
    • $adUserManager = Get-ADUser * -Properties Manager | Select-Object Name, @{n="ManagerName";e={(Get-ADUser -Identity $_.Manager -Properties displayName).DisplayName}}

    • Moved by Bill_Stewart Friday, March 9, 2018 7:12 PM Abandoned
    Tuesday, June 20, 2017 10:57 AM

All replies

  • You would output this after the pipeline. Where you have selected other things to output such as the name. I would also recommend formatting your code or at least using the "post code" option when asking for help.
    Tuesday, June 20, 2017 11:25 AM
  • Thanks Mark.  I will use that option next time.  First time posting. 
    Tuesday, June 20, 2017 3:05 PM