After Scraping the Internet for a day i found a solution that works..
$usn = (Get-ADUser -Filter "EmailAddress -eq '$x'" -Properties * -SearchBase "dc=xyz" -Server xyz.i:123 | Select *).SamAccountName
thanks anyway :)
Best regards,
TheLionFox
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hey,
can someone tell me how i can manage to get this line of code working ?
Problem is that $x is not seen/accepted as variable....
$usn = (Get-ADUser -Filter {EmailAddress -eq "$x"} -Properties * -SearchBase "dc=xyz" -Server xyz.i:123 | Select *).SamAccountName
the position of $x must be a variable, but somehow it's not reading it as a variable and i got no output...
Answer accepted by question author
After Scraping the Internet for a day i found a solution that works..
$usn = (Get-ADUser -Filter "EmailAddress -eq '$x'" -Properties * -SearchBase "dc=xyz" -Server xyz.i:123 | Select *).SamAccountName
thanks anyway :)
Best regards,
TheLionFox
Hi,
If curly braces are used to enclose the filter, the variable should not be quoted
$usn = (Get-ADUser -Filter {EmailAddress -eq $x} -Properties * -SearchBase "dc=xyz" -Server xyz.i:123 | Select *).SamAccountName
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.