Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Getting CSV dump of AD objects with certain attribute values

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 12-11-2006   #1 (permalink)
sbq
Guest


 

Getting CSV dump of AD objects with certain attribute values

Every week I dump out certain exchange related AD objects (users, groups, &
contacts) to a CSV file along with relevant attribute values (proxyAddresses,
homeMDB, etc). I use these dumps to keep a historical record of objects as I
frequently get asked about past object attributes (what group was this user
in 6 months ago, what server/database was their mailbox on, etc).

I used to do this with a hacked batch file that a ROSS engineer showed me
when doing one of our ExRAP's. Then when powershell RC1 came out I converted
to that (especially since csvde has a lot of problems when dumping AD). I
figured out how to do it with RC1 thanks to MOW's excellent powershell AD
blog posts, but now that RTM is out I need to figure out how to do this all
over again since I'm moving this function off of my desktop and onto a
production server. Here is how I was doing it with RC1 (this is the User
dump script, I also have seperate scripts for groups and contacts):

--
$domain = New-Object System.DirectoryServices.DirectoryEntry
$DN1 = (get-content C:\TempLocation_for_webposting\DN-import.txt) # list of
OU's I want dumped out

$DN2 = $DN1 | foreach {
$domain.get_children().find($_)
}

filter Format-DumpADUser {
$_ | select @{name='distinguishedName';Expression={$_.distinguishedName} },
@{ name='homeMDB'; Expression={$_.homeMDB} },
@{ name='displayName'; Expression={$_.displayName} },
@{ name='mail'; Expression={$_.mail} },
@{ name='legacyExchangeDN'; Expression={$_.legacyExchangeDN} },
@{ name='proxyAddresses'; Expression={$_.proxyAddresses} },
@{ name='memberOf'; Expression={$_.memberOf} },
@{ name='whenChanged'; Expression={$_.whenChanged} },
@{ name='whenCreated'; Expression={$_.whenCreated} },
@{ name='mailNickname'; Expression={$_.mailNickname} },
@{ name='mDBUseDefaults'; Expression={$_.mDBUseDefaults} },
@{ name='mDBOverQuotaLimit'; Expression={$_.mDBOverQuotaLimit} },
@{ name='mDBStorageQuota'; Expression={$_.mDBStorageQuota} }
}

$DN2 | foreach {
$_.get_children()
} | Format-DumpADUser | export-csv -NoTypeInformation
C:\TempLocation_for_webposting\userDump.csv

--

I did some research on the new ADSI wrapper and tried to get started, but
once I mapped a paticular OU
($MyOU=[ADSI]"LDAP://server:389/OU=ChildOU,ParentOU,DC=domain,DC=com") I
couldn't figure out how to get a list of the objects in it, .get_children()
doesn't seem to work anymore. Is there some way around this, or some new way
to do things in AD?

p.s. I have absolutely no programming or scripting experience except the few
powershell things I've done over the past few months, so please be kind when
explaining things.

My System SpecsSystem Spec
Old 12-11-2006   #2 (permalink)
/\\/\\o\\/\\/ [MVP]
Guest


 

Re: Getting CSV dump of AD objects with certain attribute values

you need to add PSbase to get arround the wrapper like :

$domain.get_children().find($_)

-->

$domain.PSBase.Children.find($_)

for more info see this 2 blogentries I made about the changes :
http://mow001.blogspot.com/2006/09/p...directory.html
part 1
http://mow001.blogspot.com/2006/09/p...ectory_29.html
part 2

Glad to hear my blog was at help before

Greetings /\/\o\/\/

"sbq" <sbq@discussions.microsoft.com> wrote in message
news:8F5605EA-9C01-407F-82AF-B731321E9291@microsoft.com...
> Every week I dump out certain exchange related AD objects (users, groups,
> &
> contacts) to a CSV file along with relevant attribute values
> (proxyAddresses,
> homeMDB, etc). I use these dumps to keep a historical record of objects
> as I
> frequently get asked about past object attributes (what group was this
> user
> in 6 months ago, what server/database was their mailbox on, etc).
>
> I used to do this with a hacked batch file that a ROSS engineer showed me
> when doing one of our ExRAP's. Then when powershell RC1 came out I
> converted
> to that (especially since csvde has a lot of problems when dumping AD). I
> figured out how to do it with RC1 thanks to MOW's excellent powershell AD
> blog posts, but now that RTM is out I need to figure out how to do this
> all
> over again since I'm moving this function off of my desktop and onto a
> production server. Here is how I was doing it with RC1 (this is the User
> dump script, I also have seperate scripts for groups and contacts):
>
> --
> $domain = New-Object System.DirectoryServices.DirectoryEntry
> $DN1 = (get-content C:\TempLocation_for_webposting\DN-import.txt) # list
> of
> OU's I want dumped out
>
> $DN2 = $DN1 | foreach {
> $domain.get_children().find($_)
> }
>
> filter Format-DumpADUser {
> $_ | select
> @{name='distinguishedName';Expression={$_.distinguishedName} },
> @{ name='homeMDB'; Expression={$_.homeMDB} },
> @{ name='displayName'; Expression={$_.displayName} },
> @{ name='mail'; Expression={$_.mail} },
> @{ name='legacyExchangeDN'; Expression={$_.legacyExchangeDN} },
> @{ name='proxyAddresses'; Expression={$_.proxyAddresses} },
> @{ name='memberOf'; Expression={$_.memberOf} },
> @{ name='whenChanged'; Expression={$_.whenChanged} },
> @{ name='whenCreated'; Expression={$_.whenCreated} },
> @{ name='mailNickname'; Expression={$_.mailNickname} },
> @{ name='mDBUseDefaults'; Expression={$_.mDBUseDefaults} },
> @{ name='mDBOverQuotaLimit'; Expression={$_.mDBOverQuotaLimit} },
> @{ name='mDBStorageQuota'; Expression={$_.mDBStorageQuota} }
> }
>
> $DN2 | foreach {
> $_.get_children()
> } | Format-DumpADUser | export-csv -NoTypeInformation
> C:\TempLocation_for_webposting\userDump.csv
>
> --
>
> I did some research on the new ADSI wrapper and tried to get started, but
> once I mapped a paticular OU
> ($MyOU=[ADSI]"LDAP://server:389/OU=ChildOU,ParentOU,DC=domain,DC=com") I
> couldn't figure out how to get a list of the objects in it,
> .get_children()
> doesn't seem to work anymore. Is there some way around this, or some new
> way
> to do things in AD?
>
> p.s. I have absolutely no programming or scripting experience except the
> few
> powershell things I've done over the past few months, so please be kind
> when
> explaining things.


My System SpecsSystem Spec
Old 12-11-2006   #3 (permalink)
Rob Campbell
Guest


 

RE: Getting CSV dump of AD objects with certain attribute values

MOW has an excellent series on the new ADSI wrapper.

I believe the answer to your immediate question is $MyOU.psbase.children

"sbq" wrote:

> Every week I dump out certain exchange related AD objects (users, groups, &
> contacts) to a CSV file along with relevant attribute values (proxyAddresses,
> homeMDB, etc). I use these dumps to keep a historical record of objects as I
> frequently get asked about past object attributes (what group was this user
> in 6 months ago, what server/database was their mailbox on, etc).
>
> I used to do this with a hacked batch file that a ROSS engineer showed me
> when doing one of our ExRAP's. Then when powershell RC1 came out I converted
> to that (especially since csvde has a lot of problems when dumping AD). I
> figured out how to do it with RC1 thanks to MOW's excellent powershell AD
> blog posts, but now that RTM is out I need to figure out how to do this all
> over again since I'm moving this function off of my desktop and onto a
> production server. Here is how I was doing it with RC1 (this is the User
> dump script, I also have seperate scripts for groups and contacts):
>
> --
> $domain = New-Object System.DirectoryServices.DirectoryEntry
> $DN1 = (get-content C:\TempLocation_for_webposting\DN-import.txt) # list of
> OU's I want dumped out
>
> $DN2 = $DN1 | foreach {
> $domain.get_children().find($_)
> }
>
> filter Format-DumpADUser {
> $_ | select @{name='distinguishedName';Expression={$_.distinguishedName} },
> @{ name='homeMDB'; Expression={$_.homeMDB} },
> @{ name='displayName'; Expression={$_.displayName} },
> @{ name='mail'; Expression={$_.mail} },
> @{ name='legacyExchangeDN'; Expression={$_.legacyExchangeDN} },
> @{ name='proxyAddresses'; Expression={$_.proxyAddresses} },
> @{ name='memberOf'; Expression={$_.memberOf} },
> @{ name='whenChanged'; Expression={$_.whenChanged} },
> @{ name='whenCreated'; Expression={$_.whenCreated} },
> @{ name='mailNickname'; Expression={$_.mailNickname} },
> @{ name='mDBUseDefaults'; Expression={$_.mDBUseDefaults} },
> @{ name='mDBOverQuotaLimit'; Expression={$_.mDBOverQuotaLimit} },
> @{ name='mDBStorageQuota'; Expression={$_.mDBStorageQuota} }
> }
>
> $DN2 | foreach {
> $_.get_children()
> } | Format-DumpADUser | export-csv -NoTypeInformation
> C:\TempLocation_for_webposting\userDump.csv
>
> --
>
> I did some research on the new ADSI wrapper and tried to get started, but
> once I mapped a paticular OU
> ($MyOU=[ADSI]"LDAP://server:389/OU=ChildOU,ParentOU,DC=domain,DC=com") I
> couldn't figure out how to get a list of the objects in it, .get_children()
> doesn't seem to work anymore. Is there some way around this, or some new way
> to do things in AD?
>
> p.s. I have absolutely no programming or scripting experience except the few
> powershell things I've done over the past few months, so please be kind when
> explaining things.

My System SpecsSystem Spec
Old 12-11-2006   #4 (permalink)
sbq
Guest


 

Re: Getting CSV dump of AD objects with certain attribute values

Thanks! this did the trick.

"/\/\o\/\/ [MVP]" wrote:

> you need to add PSbase to get arround the wrapper like :
>
> $domain.get_children().find($_)
>
> -->
>
> $domain.PSBase.Children.find($_)
>
> for more info see this 2 blogentries I made about the changes :
> http://mow001.blogspot.com/2006/09/p...directory.html
> part 1
> http://mow001.blogspot.com/2006/09/p...ectory_29.html
> part 2
>
> Glad to hear my blog was at help before
>
> Greetings /\/\o\/\/
>
> "sbq" <sbq@discussions.microsoft.com> wrote in message
> news:8F5605EA-9C01-407F-82AF-B731321E9291@microsoft.com...

[snip]
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
User attribute Ian_1 PowerShell 10 05-27-2008 09:06 AM
Getting all values out of an array of objects casey.daniell PowerShell 6 02-22-2008 09:57 AM
How to insert the "modified time" attribute in "date taken" attribute in batch mode-in vista or theough a software? paltry Vista file management 0 11-08-2006 03:06 PM
What is file attribute N? Chris Vista General 0 06-27-2006 02:16 PM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008