Computer Information from AD

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.