Alex
asked on
Get Samaccountname from email
Afternoon
My brain is fried, I'm feeling rough and sweating loads.
Why isn't this working?
My brain is fried, I'm feeling rough and sweating loads.
$users = Import-csv C:\temp\Manager.csv
foreach ($User in $Users){
Get-aduser -Properties * -Filter {(mail -like $_.'Line Manager Email')}}
Why isn't this working?
Most likely reason: you're using the ForEach statement with a named loop variable, not the ForEach-Object cmdlet, but are using "$_" as loop variable in the filter. Change either the loop type or the variable and try again.
ASKER
So something like this?
Import-csv C:\temp\Manager.csv | foreach-object | Get-aduser -Properties * -Filter {(mail -like $_.'Line Manager Email')}
I tried that and it still didn't like it :(
Import-csv C:\temp\Manager.csv | foreach-object | Get-aduser -Properties * -Filter {(mail -like $_.'Line Manager Email')}
I tried that and it still didn't like it :(
ASKER
I also tried
$users = Import-csv C:\temp\Manager.csv
foreach ($User in $Users){
Get-aduser -Properties * -Filter {(mail -like $user.'Line Manager Email')}}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Urgh, powershell is silly.... :(
Thank you, at least it wasn't entirely me being stupid.
Thank you, at least it wasn't entirely me being stupid.