Output of powershell script not working correctly?

Ok, so I've been working on a script for work for a day or two. I'm very new to powershell but learning slowly. I've trimmed down a script I bought. Basically the ONLY thing I need to do is get the NIC model or description from all of the remote servers on our forest. Which is close to 1k. The script currently works, however it outputs 4 times for every host name or IP.

What am I doing wrong here? Here is the script.

http://pastebin.com/D3qfmyX1

Answers


It looks like you have more problems then duplicates. You're looping a FILEPATH(char array, $ipaddresses).

Try something like this:

$infile = Read-Host 'What is the path of your call file (absolute path, ex. "c:\test\file.txt")?'
$servers = Get-Content $infile
$outfile = Read-Host -Prompt 'Please specify the path at which you would like ot save your file. (CSV)'
New-Item $outfile -ItemType File -Force

Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $servers | Select-Object PSComputerName, Description | 
Export-Csv $outfile -NoTypeInformation -Delimiter ";"

Invoke-Item $outfile
Read-Host -Prompt 'Your file has been saved at your destination, Good bye'

Need Your Help

Tablets hover on first click, click on second click

ios css hover click tablet

Posting this question largely in the hopes of confirming my suspicions of the behaviour, and thus documenting it for other programmers. (Since I found no record of this anywhere online)

How to connect to database without opening NetBeans?

java database jdbc connection derby

I have created a Java application that uses a database, and I now want to build it into a jar file and make it so that the database works without NetBeans. I thought NetBeans would automatically in...