I have this long line I want to make easier to read:
$Mail = "[email protected]"
Get-ADUser -Server example.com:3268 -Filter {EmailAddress -eq $Mail} -Properties CN,co,Company,Department,DisplayName,SamAccountName,State,Office,EmailAddress
I read that it's nice to use splatting, so I'm trying:
$Params = @{
Server = 'example.com:3268'
Filter = '{ EmailAddress -eq $Mail }'
Properties = 'CN,co,Company,Department,DisplayName,SamAccountName,State,Office,EmailAddress'
}
Get-ADUser @Params
But running this throws an error:
Get-ADUser : Error parsing query: '{ EmailAddress -eq [email protected] }' Error Message: 'syntax error' at position: '1'. At line:1 char:1 + Get-ADUser @Params + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ParserError: (:) [Get-ADUser], ADFilterParsingException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADFilterParsingException,Microsoft.ActiveDirectory.Management.Commands.GetADUser
What am I missing?