PowerShell – Cache AD User Lookup

Given a filter value, this PowerShell function will query Active Directory to find a matching user object and store results in a memory cache. By default “samAccountName” is used for filter. Optional field name can be provided to filter by any field such as Manager, Mail, or DN.