# Computer Information from AD

**URL:** <https://forums.powershell.org/t/computer-information-from-ad/887>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/computer-information-from-ad/887 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/computer-information-from-ad/887/1 "2011-12-31T18:30:00Z")

</div>

by obiwein at 2013-04-22 07:35:06

> Trying to pull from Active Directory a list of all computer objects along with various information for each.  
>   
> So far have this which is working:  
> Get-QADComputer -SizeLimit 10000 | Select-Object Name, NTAccountName, OSName, OSVersion, OSServicePack, Description |export-csv -path z:\script\assets.csv  
>   
> Also want to grab the serial number with something like this:  
> Get-WMIObject -Class "Win32\_BIOS" -Computer $computer  
>   
> Need some help putting the two things together in a foreach loop and then getting it to correctly export to a CSV file.

by ArtB0514 at 2013-04-22 07:55:40

> You can’t do that in a one-liner. You’ll need to do something like this:  
> `$Data = @()Get-QADComputer -SizeLimit 0 | Foreach-Object $Computer = $ $BIOS = Get-WMIObject Win32_BIOS -ComputerName $Compter.Name $Data += New-Object PSObject -Property @{ 'Name' = $Computer.Name 'NTAccountName' = $Computer.NTAccountName 'OS Name' = $Computer.OSName 'OS Version' = $Computer.OSVersion 'Service Pack' = $Computer.OSServicePack 'Description' = $Computer.Description 'BIOS' = $BIOS.BIOSVersion 'BIOS Version' = $BIOS.SMBIOSBIOSVersion 'Manufacturer' = $BIOS.Manufacturer 'Serial No' = $BIOS.SerialNumber }$Data | Export-CSV Z]`

_by obiwein at 2013-04-22 08:17:49_

_> Fixed line 4 $Compter to $Computer.  
>   
> I get the following when running:  
>   
> cmdlet ForEach-Object at command pipeline position 2  
> Supply values for the following parameters:  
> Process[0]]  
>   
> Pressing Enter twice gets past this, but the resulting CSV is empty except for column headers._

_by MasterOfTheHat at 2013-04-22 08:26:07_

_> You should be able to do that in a one-liner… I don’t use the Quest cmdlets, but here’s the basic equivalent, (I think), in the built-in cmdlets:  
> `Get-ADComputer -ResultSetSize 100 -Filter * -Properties * | Select-Object name,SamAccountName,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack,Description | Export-Csv c]`_

_by obiwein at 2013-04-22 08:29:36_

_> [quote="MasterOfTheHat"]Get-ADComputer -ResultSetSize 100 -Filter \* -Properties \* | Select-Object name,SamAccountName,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack,Description | Export-Csv c]  
>   
> That doesn’t include serial number though._

_by MasterOfTheHat at 2013-04-22 08:45:16_

> _Whoops! Missed that part of your post. Sorry…_  
>   
> _Art’s post is missing the brackets for the ForEach-Object cmdlet. Try this:  
> `Import-Module ActiveDirectory$Data = @()Get-QADComputer -SizeLimit 0 | Foreach-Object { $Computer = $`_` $BIOS = Get-WMIObject Win32_BIOS -ComputerName $Computer.Name $Data += New-Object PSObject -Property @{ 'Name' = $Computer.Name 'NTAccountName' = $Computer.NTAccountName 'OS Name' = $Computer.OSName 'OS Version' = $Computer.OSVersion 'Service Pack' = $Computer.OSServicePack 'Description' = $Computer.Description 'BIOS' = $BIOS.BIOSVersion 'BIOS Version' = $BIOS.SMBIOSBIOSVersion 'Manufacturer' = $BIOS.Manufacturer 'Serial No' = $BIOS.SerialNumber }}$Data | Export-CSV Z]`

by ArtB0514 at 2013-04-22 08:52:30

> Sorry about that! Thanks for the catch.

by obiwein at 2013-04-22 09:55:46

> Perfect.  
> Thanks a bunch for the help.

---

<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:58pm UTC](https://forums.powershell.org/t/computer-information-from-ad/887/2 "2024-05-16T20:58:28Z")

</div>


