Code to extract members from AD Group doesn't work anymore


i had written code works me very well.

cls $gname = "depta-users-write-all-user" #gname = "ad.role.depta.users.write.all.user" $ds = new-object ("system.directoryservices.directorysearcher")  $ds.filter = "(&(objectclass=group)(name=$gname))" $de = $ds.findone() if ($de -ne $null) {	   $dn = $de.properties["distinguishedname"]   $ds.filter = "(&(objectclass=user)(memberof=$dn))"   foreach ($item in $ds.findall()) {     echo $item.properties["distinguishedname"]   }	 }

now if comment out 2nd line , uncomment 3rd line. code prints nothing... though $gname @ line 3 valid group , has many users.... code fails , prints nothing.

i don't understand why code broke.


val it: unit=()


damn permissions thing. running same code a higher privilege account resolved issue.

val it: unit=()



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group