microsoft / Requirements

PowerShell framework for declaratively defining and idempotently imposing system configurations
MIT License
159 stars 26 forks source link

Latest 2.3.1 version of Requirements module throws an error about pipeline input for Invoke-Requirement #50

Closed pcgeek86 closed 4 years ago

pcgeek86 commented 4 years ago

Reproduction

$Requirements = @(
    @{
        Name = 'vscode-powershell'
        Describe = 'VSCode PowerShell Extension is installed'
        Test = { (code --list-extensions) -match 'ms\-vscode\.powershell' }
        Set = {
            $VSCodePowerShell = 'https://github.com/PowerShell/vscode-powershell/releases/download/v2019.9.0/PowerShell-2019.9.0.vsix'
            Invoke-WebRequest -OutFile ~/powershell.vsix -Uri $VSCodePowerShell
            code --install-extension ~/powershell.vsix
        }
    }
)

$RequirementsResult = $Requirements | Invoke-Requirement

Expected Result

Invoke-Requirement runs successfully.

Actual Result

Invoke-Requirement : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At line:1 char:39
+ $RequirementsResult = $Requirements | Invoke-Requirement
+                                       ~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (System.Collections.Hashtable:Hashtable) [Invoke-Requirement], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Invoke-Requirement

Workaround

chriskuech commented 4 years ago

There were some design issues carried over from v1, so v2.3 introduced some breaking changes to fix these issues. As a result, we no longer support a Name property. Check out the Patterns section of the README to see how to best leverage the design improvements.