patelbg2001
asked on
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
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
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
}
}
Try.. ForEach ($connector in $Hash.Keys)
If future please open new question for additional requests.. :-)
If future please open new question for additional requests.. :-)
ASKER
Method invocation failed because [System.Collections.Hashta ble] doesn't contain a method named 'keys'
This returns what i need, but how do i check each connector value, matches my variable?
This returns what i need, but how do i check each connector value, matches my variable?
ForEach($item1 in $hash.GetEnumerator()) {Echo $item1.Name}
ASKER
opened
ASKER