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.by ArtB0514 at 2013-04-22 07:55:40
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.
You can’t do that in a one-liner. You’ll need to do something like this:by obiwein at 2013-04-22 08:17:49$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]
Fixed line 4 $Compter to $Computer.by MasterOfTheHat at 2013-04-22 08:26:07
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.
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:by obiwein at 2013-04-22 08:29:36Get-ADComputer -ResultSetSize 100 -Filter * -Properties * | Select-Object name,SamAccountName,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack,Description | Export-Csv c]
[quote="MasterOfTheHat"]Get-ADComputer -ResultSetSize 100 -Filter * -Properties * | Select-Object name,SamAccountName,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack,Description | Export-Csv c]by MasterOfTheHat at 2013-04-22 08:45:16
That doesn’t include serial number though.
Whoops! Missed that part of your post. Sorry…by ArtB0514 at 2013-04-22 08:52:30
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]
Sorry about that! Thanks for the catch.by obiwein at 2013-04-22 09:55:46
Perfect.
Thanks a bunch for the help.