ProxyAddresses - filter on Get-ADUser not working with variable

80 Views Asked by At

I want to find users having in ProxyAddresses a specyfic mail address. I would like to make this two lines working

$mail = "[email protected]"
Get-ADUser -Filter {proxyaddresses -like "*$mail*"}  - not working

like this:

Get-ADUser -Filter {proxyaddresses -like "*[email protected]*"} 

I have tried those but it fails:

Get-ADUser -Filter {proxyaddresses -like "*$($mail)*"}
Get-ADUser -Filter {proxyaddresses -match "$mail"}

I would like to have this command working with a variable ($mail = "[email protected]")

0

There are 0 best solutions below