I have a Projects class defined as below:
class Projects{
[string]$Name;
[string]$FolderName;
[string]$RemoteRepo;
}
}
Then I create a hashtable:
$Prj = @{"A1" = [Projects]@{Name = 'A1'; FolderName = 'B1'; RemoteRepo = 'C1'}}
$Prj += @{"A2" = [Projects]@{Name = 'A2'; FolderName = 'B2'; RemoteRepo = 'C2'}}
$Prj += @{"A3" = [Projects]@{Name = 'A3'; FolderName = 'B3'; RemoteRepo = 'C3'}}
$Prj += @{"A4" = [Projects]@{Name = 'A4'; FolderName = 'B4'; RemoteRepo = 'C4'}}
Then, for every value in the Prj
hashtable, I want to extract the FolderName
value, add a constant string let say "www"
to it and display it.
To do so I'm doing like that:
ForEach ($p in $Prj)
{
($p.Values).FolderName + " www"
}
Instead of expected result:
B1 www
B2 www
B3 www
B4 www
I'm getting this:
B1
B2
B3
B4
www
My questions:
- Why?
- How to do to get the expected result.