-
Notifications
You must be signed in to change notification settings - Fork 33
Description
I'm not really sure of the purpose of parsing $TestExpression in Get-Poshspecparam, turning around and constructing a string from it, then invoking it with Invoke-Expression. Can you explain why this is needed?
I'm getting some errors when $TestExpression starts to become a little complex. I don't have much experience dealing with language parsing in PowerShell but my gut feeling is the logic in Get-Poshspecparam may need to be considerably more complex in order to deal with the various scriptblocks thrown at it.
The code below would be an enhancement to the LocalGroup resource which will return the group name and members but fails with a parse exception.
$expression = {
Get-CimInstance Win32_Group -Filter "Name = '$target' and LocalAccount = 'True'" |
Select-Object Name, @{Name = 'Members'; Expression = {
(Get-CimAssociatedInstance -InputObject $_ -ResultClassName Win32_UserAccount).Name}}
}The members property of the object returned should be able to be inspected with the test below.
LocalGroup 'Administrators' members { should contain 'Administrator' }This is the error I receive when testing this resource.
Thoughts?
Brandon