get-aduser-filter*-propertiesName,employeeID|Where-Object{$_.type -like"*user*"} | selectName,employeeID|out-gridview
At line:1 char:34get-aduser-filter*-propertiesName,employeeID|Where-Object{$_.type -like"*user*"} | selectName,employeeID|out-gridview
+ get-aduser-filter*-propertiesName,employeeID|Where-Object{$_.type -like"*user*"} ...
+ ~
Missing argument in parameter list.
At line:1 char:95
+ ... } | selectName,employeeID|out-gridview
+ ~
Missing argument in parameter list.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument
This works:
Get-ADUser -Filter * -Properties Name,employeeID |
Select Name,EmployeeID |
Out-GridView
Thanks Mike. However, I know that works. I put the Where-Object {$_.type -eq "User"} because the output returns a bunch of computer accounts as well.
Here's the script again...I guess copying directly from ISE got it all muddled up and hence th errors you got
get-aduser -filter * -properties Name, employeeID |
Where-Object {$_.type -eq "User" } |
select Name, employeeID |
out-gridview
If you really need to check, here's an adjustment:
Get-ADUser -Filter * -Properties Name,employeeID |
Where { $_.ObjectClass -eq 'user' } |
Select Name,EmployeeID |
Out-GridView Get-aduser never returns computer objects. That is why it is called Get-AdUser.
Raw ADSI will return mixed accounts if you don't use 'User" in your filter.
In a raw ADSI search it is "objectcategory" that differentiates.
([adsisearcher]'(&(objectclass=user)(objectcategory=person))').FindAll()
If we use only objectclass=user we will get back computer objects. A "user" is an account that accesses domain resources. TO get only people type accounts we have to ad "objectcategory=person". Get-AdUser does all of this by default. What you will have to filter out are template accounts and service accounts.
Can you tell us more about the computer accounts returned by Get-ADUser? Do they have objectClass "Computer" (in addition to "User")? Do they have a sAMAccountName that ends with the "$" character? Do they have objectCategory "Computer"?
I have never seen computer objects returned by Get-ADUser.
In a raw ADSI search it is "objectcategory" that differentiates.
([adsisearcher]'(&(objectclass=user)(objectcategory=person))').FindAll()
If we use only objectclass=user we will get back computer objects. A "user" is an account that accesses domain resources. TO get only people type accounts we have to ad "objectcategory=person". Get-AdUser does all of this by default. What you will have to filter out are template accounts and service acc


