$computers = Get-ADComputer -filter {OperatingSystem -like '*server*'} -Properties * | Select Name,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack, PrimaryGroup,IPv4Address,IPv6Address,CanonicalName,WhenCreated, LastlogonTimestamp,PasswordLastSet,@{Name="Disabled"; Exp={$_.useraccountcontrol -band 2}}| ?{$_.Disabled -eq 0}
#@{Name="Bios"; Exp={(gwmi win32_bios -computername $_.Name | select Name,SerialNumber,Version)}},
#@{Name="BaseBoard"; Exp={(gwmi win32_BaseBoard -computername $_.Name | select Name,Manufacturer,Product,SerialNumber,Status)}},
#@{Name="SystemInfo"; Exp={(gwmi win32_ComputerSystemProduct -ComputerName $_.Name | Select Vendor,Version,Name,IdentifyingNumber,UUID)}}| ?{$_.Disabled -eq 0}
# @{Name="NetWorkAdapters"; Exp={(gwmi win32_networkadapter -ComputerName $_.name | Select Name,Manufacturer,Description ,AdapterType,Speed,MACAddress,NetConnectionID)}},
# Out CSV Format
echo "Name,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack,PrimaryGroup,IPv4Address,BiosName,BiosSN,BiosVer,BBName,BBManufacturer,BBProduct,BBSerialNumber,SIVendor,SIIN" > computers-inventory.csv
foreach ($comp in $computers) {
$Bios = gwmi win32_bios -computername $comp.Name | select Name,SerialNumber,Version
$BaseBoard = gwmi win32_BaseBoard -computername $comp.Name | select Name,Manufacturer,Product,SerialNumber,Status
$SystemInfo = gwmi win32_ComputerSystemProduct -ComputerName $comp.Name | Select Vendor,Version,Name,IdentifyingNumber,UUID
$out = $comp.Name + ","
$out += $comp.OperatingSystem + ","
$out += $comp.OperatingSystemVersion + ","
$out += $comp.OperatingSystemServicePack + ","
$out += $comp.PrimaryGroup + ","
$out += $comp.IPv4Address + ","
$out += $Bios.Name + ","
$out += $Bios.SerialNumber + ","
$out += $Bios.Version + ","
$out += $BaseBoard.Name + ","
$out += $BaseBoard.Manufacturer + ","
$out += $BaseBoard.Product + ","
$out += $BaseBoard.SerialNumber + ","
$out += $SystemInfo.Vendor + ","
$out += $SystemInfo.IdentifyingNumber + ","
# $out += "`n"
echo $out >> computers-inventory.csv
}