0

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

1 Answer 1

1

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'
Sign up to request clarification or add additional context in comments.

2 Comments

I'm just curious. Will this run as a list? like if I were to have 1000 host names/IP's?
Yes. Just try it. Make a textfile with one ip or hostname per line(nothing else), and specify it in the prompt for "call file". This exports it as a csv file so you could open it in Excel or another app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.