Need help with PS script utilizing Quest Active Directory Management Shell
hi,
i'm trying develop simple script members of ad distribution groups , nested groups.
add-pssnapin quest.activeroles.admanagement $pw = "12345678" $password = convertto-securestring -string $pw -asplaintext -force connect-qadservice -service '10.0.0.1' -connectionaccount 'tstdom\batuhanc' -connectionpassword $password $arrgroup = get-qadgroup -grouptype 'distribution' foreach ($ogroup in $arrgroup) { get-qadgroupmember $ogroup -type 'user' -indirect }
this script gives me users direct members of group and members of nested groups in format each user:
objectsid : 010500000000000515000000e014796ea2c8d2952da90f2e39130000 objectclass : {top, person, organizationalperson, user} objectguid : 134c334a9af2fb48932bb838df04ce79 sn : smith whencreated : 12.11.2010 11:00:01 whenchanged : 12.11.2010 11:00:01 givenname : john l : facsimiletelephonenumber : mail : mobile : physicaldeliveryofficename : telephonenumber : st : wwwhomepage : city : company : department : email : fax : firstname : john homephone : initials : lastname : smith logonname : johns manager : mobilephone : office : pager : phonenumber : postalcode : 20772 postofficebox : primarygroupid : 513 stateorprovince : streetaddress : title : webpage : homedirectory : homedrive : profilepath : logonscript : userprincipalname : johns tsprofilepath : tshomedirectory : tshomedrive : tsallowlogon : true tsremotecontrol : disable tsmaxdisconnectiontime : 00:00:00 tsmaxconnectiontime : 00:00:00 tsmaxidletime : 00:00:00 tsreconnectionaction : anycomputer tsbrokenconnectionaction : disconnect tsconnectclientdrives : false tsconnectprinterdrives : false tsdefaulttomainprinter : false tsworkdirectory : tsinitialprogram : accountexpires : passwordlastset : 12.11.2010 11:00:01 passwordage : 10.22:28:01.1160458 passwordexpires : 24.12.2010 11:00:01 lastlogontimestamp : lastlogon : lastlogoff : accountisdisabled : false accountislockedout : false passwordneverexpires : false usermustchangepassword : false accountisexpired : false passwordisexpired : false accountexpirationstatus : never passwordstatus : expires at: 24 aralık 2010 cuma ntaccountname : samaccountname : johns security : quest.activeroles.arspowershellsnapin.ui.securitydescriptor domain : lastknownparent : memberof : {cn=dld_gr2,ou=imobjects,ou=im_accounts,dc=tstdom,dc=com} nestedmemberof : {cn=dld_gr1,ou=imobjects,ou=im_accounts,dc=tstdom,dc=com} notes : allmemberof : {cn=dld_gr2,ou=imobjects,ou=im_accounts,dc=tstdom,dc=com, cn=dld_gr1,ou=imobjects,ou=im_accoun ts,dc=tstdom,dc=com} keywords : {} path : ldap://10.0.0.1/cn=john smith,ou=imobjects,ou=im_accounts,dc=tstdom,dc=com dn : cn=john smith,ou=imobjects,ou=im_accounts,dc=tstdom,dc=com canonicalname : tstdom.com/im_accounts/imobjects/john smith creationdate : 12.11.2010 11:00:01 modificationdate : 12.11.2010 11:00:01 parentcontainer : tstdom.com/im_accounts/imobjects parentcontainerdn : ou=imobjects,ou=im_accounts,dc=tstdom,dc=com name : john smith classname : user type : user guid : 4a334c13-f29a-48fb-932b-b838df04ce79 sid : s-1-5-21-1853428960-2513619106-772778285-4921 description : displayname : john smith (director - gr) operationid : operationstatus : unknown cache : quest.activeroles.arspowershellsnapin.businesslogic.objectcache connection : quest.activeroles.arspowershellsnapin.data.arsadconnection directoryentry : system.directoryservices.directoryentry now need displaynames of these users using;
$omemberdisplayname = get-qaduser $omember.displayname
to do that, need these people variable $omembers , use nested "foreach" statement;
add-pssnapin quest.activeroles.admanagement $pw = "12345678" $password = convertto-securestring -string $pw -asplaintext -force connect-qadservice -service '10.0.0.1' -connectionaccount 'tstdom\batuhanc' -connectionpassword $password $arrgroup = get-qadgroup -grouptype 'distribution' foreach ($ogroup in $arrgroup) { $omembers = get-qadgroupmember $ogroup -type 'user' -indirect }
when try bind output varible named $omembers, it only contains last user output of first script. , if add displayname part, returns displayname of last user.
i need learn why first script returns users , second 1 returns 1 user.
thanks.
try this
add-pssnapin quest.activeroles.admanagement
$pw = "12345678"
$password = convertto-securestring -string $pw -asplaintext -force
connect-qadservice -service '10.0.0.1' -connectionaccount 'tstdom\batuhanc' -connectionpassword $password
arrgroup = get-qadgroup -grouptype 'distribution'
foreach ($ogroup in $arrgroup) {
$arrmembers = get-qadgroupmember $ogroup -type 'user' -indirect
foreach ($omember in $arrmembers) {$omember.name}
}
Windows Server > Windows PowerShell
Comments
Post a Comment