Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Keep getting System.String[] for Gateway using Get-WMIObject

$
0
0

I have been trying to add a function to grab a bunch of Network data from systems in preparation to replace a ton of older machines, but the original script was not one that I created. I've got it to work 99.9% but I need help on the last part. I am able to put the data into an Excel spreadsheet but the Gateway property from win32_networkadapterconfiguration keeps showing up as System.String[] in the Gateway column of the spreadsheet. When I Debug the code, it shows the Gateway address but also has curly braces as well, which is just because it's a String. That's fine with me but it's the only value in the Array and I can't figure out how to remove them and show the actual Gateway IP in the column. I know this may sound convoluted and even though I'm new-ish to Powershell, I still have good luck with using PS to get valuable data from systems. I just need some advice on this last part. I don't get why toString() won't remove the braces. I shouldn't even need it. I have other Properties that are Arrays of Strings, and I can just reference the index of the specific fields I need from within the Array, but I can't figure out what I'm doing wrong with an Array with only one value. Please help.

Brian Embree

Legacy Health System

Portland, OR


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>