Import-Module ActiveDirectory
$computers = Get-ADComputer -filter * -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,IPv4Addresse,sname,sversion" > soft-inventory.csv
foreach ($comp in $computers) {
$products = gwmi Win32_Product -ComputerName $comp.Name | select name, version
$out = ""
foreach ($product in $products) {
$out += $comp.Name + ","
$out += $comp.OperatingSystem + ","
$out += $comp.OperatingSystemVersion + ","
$out += $comp.OperatingSystemServicePack + ","
$out += $comp.IPv4Address + ","
$out += $product.name + ","
$out += $product.version
$out += "`n"
}
echo $out >> soft-inventory.csv
}