################################################################### ## Script to import in TeemIP ## Author: Thomas MANSUY ## Date: 02/04/2019 ################################################################### #######################PATH FILES################################### $path = "C:\Users\tmansuy\OneDrive - CRISTAL UNION\Documents\Infra\IPAM 2019\test.csv" #######################REMOVE OLD FILES################################### Remove-Item ($path) #########Add Header#### $machines = gc .\machinelist.txt $count = $machines.count $machines | foreach-object{ $ping=$null $hname =$null $machine = $_ write-host $machine $hname = [System.Net.Dns]::GetHostByAddress($machine).HostName $ping = Test-Connection $hname -Count 1 -ea silentlycontinue write-host $ping $hname=$hname.Split(".")[0] if($ping){ $ligne=$machine+";UP;"+$hname } else { $ligne=$machine+";DOWN;"+$hname } $a+=[Array]$ligne $netadapteripenabled = Get-WmiObject win32_networkadapterconfiguration -Filter 'ipenabled = "true"' foreach ($netadapteripenabledindex in $netadapteripenabled.index){ Get-WmiObject win32_networkadapter -Filter "index = $netadapteripenabledindex" | ft index, name, MACAddress } $a | out-file "$path"