- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select-PSObject
from variable?
#661
Comments
It can't do that yet Thanks for the great suggestion! |
`Select-PSObject` from variable? PowershellFrameworkCollective#661
More out of curiosity about how it works behind the scenes, I took a stab at this: FH-Inway@91b01c7 Needs obviously some work, but hopefully I'm on the right track here. Used the following tests ( $myObject = @{
Id = "Test"
}
$myVariable = "C:\Temp\test.txt"
$myObject | Select-PSFObject 'Id as Name', '$myVariable as Path'
<#
Name Path
---- ----
Test C:\Temp\test.txt
#> Just the variable also works and uses the variable name as property name. $myObject = @{
Id = "Test"
}
$myVariable = "C:\Temp\test.txt"
$myObject | Select-PSFObject 'Id as Name', '$myVariable'
<#
Name myVariable
---- ----------
Test C:\Temp\test.txt
#> |
Poked a bit more and created #664 to enable a more targeted discussion of the changes. Let me know if this is of use to you and feel free to ignore. I'm mainly working on this to satisfy my curiosity and learn something. |
Select-PSFObject
can add properties from objects other than the object it is selecting from like e.g. this:I'm wondering if it is also possible to add a property based on a variable? I tried several variations of the following, but never got the expected result.
Asked differently, is it possible to express the following two variations in a more succinct and readable way?
The text was updated successfully, but these errors were encountered: