Background
From list of predefined servernames, I'm searching in config files and trying to group for each server all the files where it's found. A filename can be mapped to an application.
Problem
The grouping part is giving me problems. It keeps returning a hashlist where I just want the filename returned.
SSCCE note: grouping is on filename in the sscce but the gist of the problem is the same
This example is showing the entire line where the match is found instead of just the match
@("A test", "Another test") | sls -pattern "\btest\b" | group filename | select name, group
Trying to adjust for that, I've added a calculated property to only get the match. Unfortunately, this shows the group as a Hashlist.
@("A test", "Another test") | sls -pattern "\btest\b" | select filename, @{n="Server";e={$_.matches[0].Value}} | group filename | select name, group
TLDR; following is what I'm currently using
@(
"server1"
, "server2"
) |
% {sls -path "C:\PrivateWS\sources\confdoc\applicaties\*.yml" -Pattern "\b$($_)\b"} |
select Filename, @{n="Server";e={$_.matches[0].Value}} |
group server | select name, group
and this returns something like this
Name Group
---- -----
server1 {@{Filename=applicationX.yml; Server=server1}, @{Filename=applicationY.yml; Server=server1}}
server2 {@{Filename=applicationX.yml; Server=server2}}
where I would like to have it return this
Name Group
---- -----
server1 {applicationX.yml, applicationY.yml}
server2 {applicationX.yml}