开发者

How to deal with System.String[]

I am using the below script line to get the IP information of system and then exporting in to a HTML file. But when I export the file the Most of the values of below command comes in System.String[], and I searched the net but not able to find how to deal with this.

Get-WmiObject win32_NetworkAdapterConfiguration | select Description,DHCPServer,IpAddress,IpSubnet,DefaultIPgateway,DNSServerSearchOrder,WinsPrimaryServer,WINSSecindaryServer | ConvertTo-Html > d:\aman.html

When I check the Properties in IPADDRESS using WMIEXPLORER tool, these are array开发者_JAVA百科s and I don't know how to manipulate them.

And I want the output in table format so that it can easily fit in to my Reports.


You could use a calculated field in the Select-Object statement and join the array.

Here, IPAddress is joined with a semicolon:

EDIT: Updated with remaning string array properties, and added a space after semicolon to allow the string to wrap in the displayed HTML

Get-WmiObject Win32_NetworkAdapterConfiguration| 
    Select-Object Description, DHCPServer, 
        @{Name='IpAddress';Expression={$_.IpAddress -join '; '}}, 
        @{Name='IpSubnet';Expression={$_.IpSubnet -join '; '}}, 
        @{Name='DefaultIPgateway';Expression={$_.DefaultIPgateway -join '; '}}, 
        @{Name='DNSServerSearchOrder';Expression={$_.DNSServerSearchOrder -join '; '}}, 
        WinsPrimaryServer, WINSSecindaryServer|
    ConvertTo-Html > .\temp.htm
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜