Link to home
Start Free TrialLog in
Avatar of Software Squirrel
Software SquirrelFlag for United States of America

asked on

PowerShell not showing info

I ran this script. It contacts AD but does not respond with results. It just waits for another entry.

C:\Save> Get-ADUser -Filter {mail -like 'emailaddress'} -Properties * | fl workid
C:\Save> _

It looks like above
Avatar of Hayes Jupe
Hayes Jupe
Flag of Australia image

AD powershell module not installed on the machine your running it from?


i run the same and get (keep in mind that "workID" doesnt exist in my AD - i assume thats a custom property in yours.)

PS C:\Windows\system32> Get-ADUser -Filter {mail -like '<email address>'} -Properties * | fl workid


workid : {}
Avatar of Software Squirrel

ASKER

Yes, it is another property, but anyway, I don't even get that.  I just get nothing.  
It acts like I just inserted:
C:\Save> Get-ADUser
C:\Save>_
Get-ADUser -Filter {mail -like '<email address>'} -Properties * | fl 

Open in new window

still indicates that the AD powershell module either inst installed or isnt loaded.

import-module activeDirectory

Open in new window

@Hayes Jupe
C:\Save>import-module activeDirectory
C:\Save>PS C:\Windows\system32> Get-ADUser -Filter {mail -like '<email address>'} -Properties * | fl workid
C:\Save>_

Also, @David Johnson, Same result after adding <...>
import-module activeDirectory -erroraction stop

Open in new window

my comment was to remove workid from 'fl workid'
David Johnson, CD 
Same after -erroraction stop
David Johnson, CD 
Removed | fl workID
Same
then it means no objects were returned from your code.
Get-ADUser -Filter {EmailAddress -like "abc@def.com"} -Properties * | Select Name, SamAccountName, EmailAddress

Open in new window

|
The first time I run in PS, it pops up the window like its processing something and then goes away quickly (so, I cannot see what it is saying). Then back to the prompt

I am not getting errors, so maybe it's just a user issue not having access to AD. I will try another user account.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That worked
so then the filter  {mail -like 'emailaddress'} is not matching try -eq instead
Get-ADUser -Filter {mail -eq 'abc@email.com'} -Properties * | fl workid
same result , nothing
Removed | fl workid
same result, nothing



it is not 'mail' but 'EmailAddress'
I tried EmailAddress with both -like and -eq
I also removed | fl workid and just ended with -Properties *
Same result

Only one with results was
Get-ADUser -Filter *  -Properties * | Select Name, SamAccountName, EmailAddress
I was able to get it with Get-ADUser -Filter {EmailAddress -eq "abc@email.com"} -Properties *
David Johnson, CD   's solution helped me identify that the values I was searching are empty.  The query I originally had was right, but I did not get feedback from my query.