get-aduser
2 TopicsHow to fetch / filter users from AD faster using Get-ADUser command.
Recently I saw few scripts which are fetching users from AD like below mentioned. Get-ADUser -LDAPFilter "(whenCreated>=$date)" or Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False -and PasswordLastSet -gt 0} or Get-ADUser -Filter 'Enabled -eq $True' But using like above is taking quite a lot of time or sometimes giving Timeout error. is there any way can make this faster? Will using -LDAPFilter instead of -Filter make it faster? Error Message: The operation returned because the timeout limit was exceeded.Solved3.9KViews0likes2CommentsCreate CSV & HTML showing AD Group, Group Description, ManagedBy (Friendly Name)
I need some help doing a search of AD groups with the Description starting with "Admin Group*" and get the Managedby friendly name. Some groups are managed by groups and other are by user. I've tried putting together something using other script examples but, I'm able to get the data but can't figure out how to export the results to CSV & HTML. Here is what I have so far: Get-ADGroup -filter { Description -like "Admin Group*"} -Properties CN, Description, ManagedBy | Sort-Object "CN" | ForEach-Object { $GroupName = $_.CN; $Description = $_.Description; $Manager = $_.Managedby; if (!$Manager) { $Manager = 'N/A'; } Get-ADUser -Filter * -SearchBase $Manager -Properties * { $GivenName = $_.GivenName; $Surname = $_.Surname; $managerName = $GivenName, $Surname; } if (!$ManagerName) { (Get-ADGroup -Filter * -SearchBase $Manager -Properties Name) | ForEach-Object { $managerName = $_.Name; } } Write-Output $Groupname, $Description, $ManagerName} It writes the output like this though: GroupName Description ManagerName GroupName Description ManagerName GroupName Description ManagerName Etc...1.9KViews0likes3Comments