![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | display active directory attributes - not easy question for experts too :-) In vbscript, i did a wscript.echo objmember.samaccountname, objmember.<attributes>, etc In Powershell, i can do similar using directorysearcher properties. My problem lies each time, my administrators wants to look at particular attribute, i've to change code to reflect what they need. I would like my script to display what they need, instead of asking me to change the code each time. Assuming the input is a text file that contains nt id, i would like a script name exportattributes.vbs or exportattributes.ps1 that allows administrators to display what they like to see. They shld type in like .\exportattributes.ps1 displayname, samaccountname <nt id.txt file>, which from reading of text file, it will display only : ntid <tab> displayname <tab> samaccountname And if they type in like .\exportattributes.ps1 cn, samaccountname <nt id.txt file>, it will display the relevant info. How do i approach the problem of coding ? |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: display active directory attributes - not easy question for experts too :-) If you think it safe to assume they will get the attribute names correct. Try this... I am on the bus and cant test it, but it should do what your looking for. Param($Attribute) if($Attribute){$props = $Attribute} else{$props = "sAMAccoutName"} # add what ever default props you want here $filter = "(objectcategory=user)" $ds = New-Object System.DirectoryServices.DirectorySearcher([ADSI]"",$filter,$prop) $ds.PageSize = 1000 $Users = $ds.FindAll() foreach($user in $users) { "+ Listing Properties for $($user.properties.samaccountname)" foreach($prop in $props) { " - $Prop : $($user.properties.$prop)" } } "IT Staff" <jkklim@xxxxxx> wrote in message news:ezp%23mH1JIHA.4584@xxxxxx
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: display active directory attributes - not easy question for experts too :-) System.DirectoryServices.DirectorySearcher([ADSI]"",$filter,$prop) #<<< should be $props "Brandon Shell [MVP]" <a_bshell@xxxxxx> wrote in message news:62A9BB12-64B6-4112-BC56-512631109B18@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Re: active directory question | Richard Mueller [MVP] | VB Script | 0 | 06-07-2008 02:30 PM |
| Active Directory Computer Attributes | Anwar Mahmood | VB Script | 6 | 06-02-2008 03:21 PM |
| Why isn't my question being displayed? - Active Directory Problem | momentarylapseofreason | Vista networking & sharing | 4 | 05-29-2008 04:10 AM |
| active directory | Walser Mark | PowerShell | 4 | 04-22-2008 08:55 AM |
| Active Directory | Lothar | PowerShell | 7 | 12-14-2006 09:29 AM |