Hello, I am trying to get the machine name, with the NIC information such as interfacealias, ipaddress, and a status of about 30 servers in a vlan. I got to 2 basic commands that do it separately, but they either overwrite the text file, and not get it all in one basically… I am thinking of running it using the invoke-command cmdlet…
You may run into problems even with the Append switch. The way you’ve set up that command, multiple computers might be trying to write to the same file at the same time, which will fail. It would be more reliable to have your remote script blocks just return objects, and do the file I/O from your local session.
I used a script block instead of FilePath just to demonstrate how the contents of the file would change. Take any calls to Out-File out of the remotely invoked script, so they just return objects. The pipe to Out-File happens locally on your machine.
[quote=11563]Also, isn’t there a “cleaner†way of coding this in PS 3.0?
[/quote]
Not that I’m aware of. There are small changes you can make, but they all boil down to splitting your pipeline into smaller parts so you can save a reference to the NetAdapter object. I don’t think you can do it all in one pipeline without the -PipelineVariable parameter.