Get-ReceiveConnector output into a hash table Name and PermissionGroups

Hi,
I've been trying to get the connector name and the permissiongroups enabled voa exchange powershell, to generate as part of a hash table which I could use as part of a general audit.  

I was looking for some help with the string data from gathered from $_.permissiongroup parameter as it is a  noteproperty object. I was wondering how I can splt the string correctly so I can use a hash table to compare against

$exsrv = $env:computername
$RC = Get-ReceiveConnector -Server $exsrv | Select-Object name, permis* | Fl * | Out-String

ForEach ($x in $RC) {
$pattern = ":"
$pattern1 = ";"

$x = $x | Out-String
$x = $x.split($Pattern,[System.StringSplitOptions]::RemoveEmptyEntries) | Where-Object {$_ -match '\S'}
$x = $x | ForEach {$_ -replace " ",""}
$x = $x | ForEach {$_ -replace "Name","ConnectorName	"}
$x = $x | ForEach {$_ -replace "PermissionGroups","PermGroups	"}
$x = $x | Out-String
$x = $x.split("",[System.StringSplitOptions]::RemoveEmptyEntries)
$x = $x | ForEach {$_ -replace "ConnectorName",";"}
$x = $x | ForEach {$_ -replace "PermGroups",";"}
$x = $x | ForEach {$_ -replace " ",""}
$x = $x | ForEach {$_ -replace ",",", "}
$x = $x | ForEach {$_ -replace ":",""}
$x = $x | Out-String
$x = $x.substring(1)
$x = $x | ForEach {$_ -replace " ","*"}
$x = $x.split($Pattern1,[System.StringSplitOptions]::RemoveEmptyEntries) | Where-Object {$_ -match '\S'}
#$x = $x | ForEach {$_ -replace ":",""}
#$x = $x.split("",[System.StringSplitOptions]::RemoveEmptyEntries)
$x = $x | Out-String
Write-Host $x -Fore Green
	}

Open in new window

LVL 6
patelbg2001Asked:
Who is Participating?
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.

SubsunCommented:
Converting to hash table is simple.. Here is an example..
$Hash = @{}
$exsrv = $env:computername
Get-ReceiveConnector -Server $exsrv | Select-Object name, permis* | %{
$Hash[$_.Name] = $_.PermissionGroups
}
$Hash

Open in new window

0

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
patelbg2001Author Commented:
thanks, I should know better by now :o)
0
patelbg2001Author Commented:
How would you qurey each connector in the hashtable?

ForEach ($connector in $Hash['Name']) {
	IF ($connector -ne $check) {
		Write-Host $connector "needs updating" -Fore Red
		} ELSE {
			Write-Host $connector "is cool mamajama" -Fore Green
		}
	}

Open in new window

0
Introducing the "443 Security Simplified" Podcast

This new podcast puts you inside the minds of leading white-hat hackers and security researchers. Hosts Marc Laliberte and Corey Nachreiner turn complex security concepts into easily understood and actionable insights on the latest cyber security headlines and trends.

SubsunCommented:
Try.. ForEach ($connector in $Hash.Keys)

If future please open new question for additional requests.. :-)
0
patelbg2001Author Commented:
Method invocation failed because [System.Collections.Hashtable] doesn't contain a method named 'keys'

This returns what i need, but how do i check each connector value, matches my variable?

ForEach($item1 in $hash.GetEnumerator()) {Echo $item1.Name}

Open in new window

0
SubsunCommented:
Untitled.pngIt does work for me.. If you need more assistance please open a new request, you can explain what you trying to achieve. So we can work on it.. Also it is possible that, there might be a better way to achieve the same..
0
patelbg2001Author Commented:
opened
0
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
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.