Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Query Users with Specific Description, export to CSV, and Include Manager?

$
0
0

I have a script to query AD users with a specific word in their description and export to a CSV file. I am trying to add a manager field to the exported file; however, the manager field contains the full path instead of just the name. I also need to the manager's logon name (userid) and display name included on the report. Here is my current script.


$users = Get-QADUser -SizeLimit 10000 -SearchRoot 'domain.com/associates' -IncludedProperties "description" | where {$_.description -like "temp*" }

@(foreach($user in $users)
{
    $user | Select-Object DisplayName,LogonName,description,manager
 
}) | export-Csv "\\server\share$\Windows Domain\test123.csv" -noType




I also found another script which pulls manager for a specific user, but don't know how to incorperate it into the script above.

Get-QADUser billybob | %{$_.Manager} | Get-QADUser | Select Name,LogonName


I am a noob when it comes to Powershell and do not know how to make this work. Any help is appreciated


Viewing all articles
Browse latest Browse all 10624

Trending Articles