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

How to convert a delimited string to an array/hash table/or something.

$
0
0

I have a string that I want to convert to some sort of output that allows me to address the pair either by name or id -- not knowing the correct terminology doesn't help.

Sample data:

"VM-Win764XD06.corp",vm-466;"BuddyPC",vm-1081;"XPVM0203",vm-339;"XPVM0206",vm-340;

This will give me an array of strings:

$GroupMembers = "VM-Win764XD06.corp",vm-466;"BuddyPC",vm-1081;"XPVM0203",vm-339;"XPVM0206",vm-340;
$GroupMembersArray =@{}
[string[]]$GroupMembersArray = $GroupMembers -split ";"

I'm thinking that hash table gives me the key pair structure I want/need. How I get to this next step in PS2?

As a bonus, how would you sort this?

P.S. I just realized that the first line will not work as I have shown. The variable does have that value through other code I have not shown.



Viewing all articles
Browse latest Browse all 21975

Trending Articles



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