Powershell: get data of netsh in hashtable


$Info = netsh mbn show interface gives below output.

How can I get this in a hashtable so I can select $Info.Name, $Info.Description etc?
I could use  $Name = $Info | Select-String  name but that gives two results. Could use $Info[6] then split select etc
... But there has to be an easier way right?


There is 1 interface on the system:

    Name               : Mobile Broadband Connection
    Description        : Wireless Mobile Broadband Network Adapter
    GUID               : {FF2782E0-33E0-4F84-92A4-EEFF24EEFFC89}
    Physical Address   : 01:a0:c8:00:06:14
    State              : Not connected
    Device type        : Mobile Broadband device is embedded in the system
    Cellular class     : GSM
    Device Id          : 3535112347061191
    Manufacturer       : Wireless, Incorporated
    Model              : SC7215
    Firmware Version   : SWI9X15C_01.12.00.01 9903149 01
    Provider Name      :
    Roaming            : Not roaming
    Signal             : 0%

Pleas advise.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

At the end of the script, $result will contain an object with the respective properties:
$properties = 'Name', 'Description', 'GUID', 'Physical Address', 'State', 'Device type', 'Cellular class', 'Device Id', 'Manufacturer', 'Model', 'Firmware Version', 'Provider Name', 'Roaming', 'Signal'
$result = '' | Select-Object -Property $properties
& netsh.exe mbn show interface | ForEach-Object {
	$key, $value = $_.Split(':', 2) | ForEach-Object {$_.Trim()}
	If ($properties -contains $key) {
		$result.$key = $value

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jose Gabriel Ortega CastroCEOCommented:
What about using regex:

$info= netsh.exe mbn show interface
$pattern="\: (.*)"

foreach($match in [System.Text.RegularExpressions.Regex]::Matches($info,$pattern)){
    switch ($i)
        1 {$name =$match.Groups[1].Value}
        2 {$Description=$match.Groups[1].Value}
        3 {$GUID =$match.Groups[1].Value}
        4 {$PA =$match.Groups[1].Value}
        5 {$state =$match.Groups[1].Value}
        6 {$dt =$match.Groups[1].Value}
        7 {$cc =$match.Groups[1].Value}
        8 {$did =$match.Groups[1].Value}
        9 {$manufacturer =$match.Groups[1].Value}
        10 {$Model =$match.Groups[1].Value}
        11 {$Firmware =$match.Groups[1].Value}
        12 {$Provider =$match.Groups[1].Value}
        13 {$Roaming =$match.Groups[1].Value}
        14 {$signal =$match.Groups[1].Value}
$final = new-object psobject -Property @{
"name"=$name; "Description" = $Description; "GUID" = $GUID; "Physical Adddress"=$PA; "state"=$state; 
"Device Type"= $dt; "Celular class"=$cc; "Device Id"= $did; "manufacturer" =$manufacturer; 
"Model"=$Model; "Firmware Version"=$Firmware; "Provider Name"=$Provider; "Roaming" =$Roaming;
"Signal" = $signal;}


Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.