This seems to run faster and gives me everything I need EXCEPT the IP address. Is there a way to modify this powershell to produce an IP Address column in the output?

If not, I've been trying to use the [System.Net.Dns]::GetHostAddresses command to retrieve the IP address. This works fine, however, when I attempt to use a text file to input, the command fails. Any recommendation on this?

I'm guessing you will have to run through the computers in a foreach loop as I think this will require at least two commands to collect the information you need. I don't think you can do it all with a one-liner.

This seems to run faster and gives me everything I need EXCEPT the IP address. Is there a way to modify this powershell to produce an IP Address column in the output?

If not, I've been trying to use the [System.Net.Dns]::GetHostAddresses command to retrieve the IP address. This works fine, however, when I attempt to use a text file to input, the command fails. Any recommendation on this?

I give up. I was supposed to have this information an hour ago. Thanks for your help guys.

Is it me or is powershell kind of a garbage way to script? Why is it so hard to return a simple list of hostnames and IP addresses?

Hostnames and IPs are not hard. There are a few ways to do it. Here's one way:

Powershell

Test-Connection$computer-Count1|selectIpv4address,address

Another is to use nslookup. Another is to use Get-NetIPAddress. There are others. Each way has it's pros and cons, though.

I think you just got frustrated with the time crunch you were given. Another is is that it's not just a 2 line script and it's done. It needs a bit more being you needed to run two commands on a remote computer.

Switching from a series of cmdlets that can be strung together in a pipeline to something just a bit more complex can involve a rather drastic change to the script.

It also does not help that the language is still evolving and that new cmdlets get released with new version of Windows. Those 2 things being different. Do the new features come with the newest version of Powershell so it can be installed on older OS's or are they exposed new functionality of the OS.

I give up. I was supposed to have this information an hour ago. Thanks for your help guys.

Is it me or is powershell kind of a garbage way to script? Why is it so hard to return a simple list of hostnames and IP addresses?

Don't quit so easily. About a year and possibly 6 months ago I couldn't even write a batch file and hell I received many comments to stop writing powershell script the way one writes a batch file but I persisted and I get far less comments like that.

Twon of An wrote:

Bobby06 wrote:

I give up. I was supposed to have this information an hour ago. Thanks for your help guys.

Is it me or is powershell kind of a garbage way to script? Why is it so hard to return a simple list of hostnames and IP addresses?

PowerShell is hard because it is so flexible. Take some time to learn it!

Assuming the txt file is simply a list of hostnames and not a csv file, here's a simple way to get just the IP address and serial number from a list of computers:

This will output everything to the console. If you need it to output to a file, append ' | Export-CSV C:\path\to\file.csv' to the last line.

Twon of An has it the right way... Custom objects may sound a bit hard to learn in the beginning but once you get used to it they can make your life so easy...

For instance I still use some batch scripts especially for when I have to query AD as I'm not that familiar with the powershell AD interface ( call it a bit nervous to test code on a live AD ). Try it & learn piece by piece. Follow the Powershell forum here and when someone posts a working script try and understand what it does. Then try to modify it slightly and see if it still works. If it does you have learned already something.

Don't be nervous and if it doesn't work from starters persist till you figure it out.