I'm trying to search Active Directory for a user with the following statement, but I get an error when I use $("smtp:$user").
get-aduser -filter {(anr -eq $user) -or (anr -eq $("smtp:$user"))}
Could anyone explain why please, or is there a better way of achieving the same result. I would like user to be able to contain, Name, email or SAM information, and use the same code to search.
get-aduser : Cannot process argument because the value of argument "path" is not valid. Change the value of the "path" argument and run the operation again.
At line:1 char:1.
get-aduser -filter {(anr -eq $user) -or (anr -eq $("smtp:$user"))}
CategoryInfo:NotSpecified: (:) [Get-ADUser], PSArgumentException
FullyQualifiedErrorId:ActiveDirectoryCmdlet:System.Management.Automation.PSArgumentException,Microsoft.ActiveDirectory.Management.Commands.GetADUser