# Active Directory computer information export

**URL:** <https://forums.powershell.org/t/active-directory-computer-information-export/22041>\
**Category:** PowerShell Help\
**Created:** [April 4, 2023, 5:37pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041 "2023-04-04T17:37:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jamie\_Robertson](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jamie\_Robertson](https://forums.powershell.org/u/Jamie_Robertson)\
**Post date:** [April 4, 2023, 5:37pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/1 "2023-04-04T17:37:59Z")

</div>

I am trying to make a script that will pull information from computers in an AD OU

It will pull the name, description and what security groups each computer belongs to I.e

computer001 - this is pc 001 - bitlocker clients, cm\_etcgroup

It works fine with an OU only with computers, however, if an OU contains security groups, or other objects it wont pull the member of group information

Any help would be appreciated

```auto
Get-ADComputer -SearchBase "OU=myOU" -server "servername" -filter * -Properties Description, MemberOf, CanonicalName | 
Select-Object Name, Description, @{Name="MemberOfGroups"; Expression={($_.MemberOf | ForEach-Object {(Get-ADGroup $_).Name})}} | 
Export-Csv -Path "C:\" -NoTypeInformation

```

---

<div class="post-metadata">

**Author:** ![neemobeer](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/neemobeer/32/4087_2.png) [@neemobeer](https://forums.powershell.org/u/neemobeer)\
**Post date:** [April 4, 2023, 6:45pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/2 "2023-04-04T18:45:35Z")

</div>

If your asking why it won’t pull info for other object types besides computers, that would be because you’re using Get-AD **COMPUTER**. Use Get-ADObject instead.

---

<div class="post-metadata">

**Author:** ![Jamie\_Robertson](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jamie\_Robertson](https://forums.powershell.org/u/Jamie_Robertson)\
**Post date:** [April 5, 2023, 5:08pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/3 "2023-04-05T17:08:54Z")

</div>

Thanks for the reply

I tried changing to Get-ADObject and it gives the same results

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 5, 2023, 6:44pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/4 "2023-04-05T18:44:38Z")

</div>

You may elaborate a little more detailed what you’re actually trying to do. It seems like you’re expecting something what’s either not possible or at least very unlikely. 😉

---

<div class="post-metadata">

**Author:** ![Jamie\_Robertson](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jamie\_Robertson](https://forums.powershell.org/u/Jamie_Robertson)\
**Post date:** [April 6, 2023, 4:38pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/5 "2023-04-06T16:38:51Z")

</div>

Sure

I need to pull the following information from certain OUs in our active directory, namely

Name of the object (mainly computers)  
Description of the object  
The names of groups those objects are members of (Properties \> Member of)

If i run the script on an OU with only computers it seems to work fine, however, the OUs i need info from have a mixture of global security groups, computers and another OU

I have attached some pictures for more clarity

 ![Screenshot 2023-04-06 173129](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/3/3a581550fe226ba54f9ecf5a200cdc36edd75948.png)  
 ![Screenshot 2023-04-06 173153](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/7/7589dd5d5f1aa350390540f16daabe7c7365d734.png)  
 ![Screenshot 2023-04-06 173206](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/4/41f45203505e71e50799283fe1c1dc510fd4be23.png)

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [April 6, 2023, 5:46pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/6 "2023-04-06T17:46:47Z")

</div>

Honestly, you haven’t cleared it up at all. You’re saying the script will pull all the info you desire properly if only computers list in the OU, otherwise it will only pull the name and description if there are other objects in the OU? Your “MemberofGroups” property just comes back blank? That makes zero sense.

---

<div class="post-metadata">

**Author:** ![Jamie\_Robertson](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jamie\_Robertson](https://forums.powershell.org/u/Jamie_Robertson)\
**Post date:** [April 6, 2023, 5:55pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/7 "2023-04-06T17:55:42Z")

</div>

Apologies if I did not make sense

I eventually got it working

```auto
$csvPath = ""
$ouDN = ""
$svr = ""

$members = Get-ADComputer -SearchBase $ouDN -server $svr -Filter {ObjectClass -eq "computer"} -Properties Name, Description, memberOf

$members | Select-Object Name, Description, @{Name="MemberOf";Expression={$_.memberOf -join "; "}} | Export-Csv -Path $csvPath -NoTypeInformation

```

This outputs only name, description and member of computers in the OU

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 6, 2023, 7:50pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/8 "2023-04-06T19:50:20Z")

</div>

> [@Jamie\_Robertson](#):
>
> This outputs only name, description and member of computers in the OU

OK. And what would you expect? It might become clearer if you showed an example of the expected output.

---

<div class="post-metadata">

**Author:** ![Jamie\_Robertson](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@Jamie\_Robertson](https://forums.powershell.org/u/Jamie_Robertson)\
**Post date:** [April 6, 2023, 7:59pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/9 "2023-04-06T19:59:05Z")

</div>

I really need to word my replies better 🤣

I got what I needed to work

Example

 ![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/6/6202f57d74918e830a072ebb797888f2d3376ba2.png)

So all good now, i appreciate everyone’s help 😃

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 6, 2023, 8:04pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/10 "2023-04-06T20:04:43Z")

</div>

> [@Jamie\_Robertson](#):
>
> I really need to word my replies better

Amen. 🙏🏼

> [@Jamie\_Robertson](#):
>
> I got what I needed to work

Great. 👍🏼

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:15pm UTC](https://forums.powershell.org/t/active-directory-computer-information-export/22041/11 "2024-05-16T20:15:00Z")

</div>


