get-aduser -filter 'name problems


hi please help

i can search user name using " get-aduser -filter 'name -like "john doe" | select name, samaccountname

but i trying search using variable. when try get-aduser -filter 'name -like '$row.managedby'' | select name, samaccountname

get-aduser : positional parameter cannot found accepts argument 'john doe'.

at line:1 char:1

+ get-aduser -filter 'name -like '$row.managedby''

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + categoryinfo          : invalidargument: (:) [get-aduser], parameterbindingexception

    + fullyqualifiederrorid : positionalparameternotfound,microsoft.activedirectory.management.commands.getaduser

 

hi,

you're using incorrect quotes , need use subexpression.

also note managedby returns full dn, name won't you.

$row = get-adgroup 'test group 1' -properties managedby  get-aduser -filter "distinguishedname -eq '$($row.managedby)'"




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file