Hi all,
here is my code to export bunch of inventory to a text file.
$ADInfo = Get-ADDomain $allDCs = $ADInfo.ReplicaDirectoryServers foreach ($item in $allDCs) { $processor1 = (gwmi win32_processor -ComputerName $item).Name $RAM = (gwmi win32_ComputerSystem -ComputerName $item).TotalPhysicalMemory $memory = [math]::Round($RAM/1024/1024/1024, 0) $TimeZone0 = (gwmi Win32_TimeZone -ComputerName $item).caption $TimeZone1 = $TimeZone0 -replace ":", "" $TimeZone = $TimeZone1 -replace " ", "" $IPGateway0 = (gwmi win32_NetworkAdapterConfiguration -ComputerName $item | where {$_.IPEnabled -eq "True"}).DefaultIPGateway foreach ($ipgw in $IPGateway0) { $IPGateway = $ipgw | Out-String } $NICs = Get-ADComputer -Filter * -Properties ipv4Address | where {$_.DNSHostName -like "$item"} | foreach {$_.ipv4address} foreach ($NICItem in $NICs) { $IPAddress2 = $NICItem | Out-String"$item : {0} : {1} GB : {2} : {3} : {4}" -f $processor1,$memory,$TimeZone,$IPAddress2,$IPGateway >> c:\scripts\hardware.log } }
It exports data to hardware.log file. But for the last variable (IPGateway or anything i put) it breaks line and add something like that:
Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz + 1 + (UTC+0200)Minsk + 10.0.0.2+ 100.0.8.7
Any idea?