PowerShellGuard icon indicating copy to clipboard operation
PowerShellGuard copied to clipboard

Example does not work

Open nohwnd opened this issue 10 years ago • 0 comments

Running the second example yields lot of these errors:

PS C:\Projects\PSTMigration> dir *.ps1 | New-Guard -TestPath {"./Tests/$($_.basename).Tests.ps1"}
Resolve-Path : Cannot evaluate parameter 'Path' because its argument is specified as a script block and there is no
input. A script block cannot be evaluated without input.
At C:\Projects\PowerShellGuard\PowerShellGuard.psm1:52 char:33
+       $TestPath = (resolve-path $TestPath).Path
+                                 ~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [Resolve-Path], ParameterBindingException
    + FullyQualifiedErrorId : ScriptBlockArgumentNoInput,Microsoft.PowerShell.Commands.ResolvePathCommand

Adding ValueFromPipeline=$true to $Path does not solve the issue, it only changes the error to:

Resolve-Path : Cannot evaluate parameter 'Path' because its argument is specified as a script block and there is no
input. A script block cannot be evaluated without input.
At C:\Projects\PowerShellGuard\PowerShellGuard.psm1:52 char:33
+       $TestPath = (resolve-path $TestPath).Path
+                                 ~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [Resolve-Path], ParameterBindingException
    + FullyQualifiedErrorId : ScriptBlockArgumentNoInput,Microsoft.PowerShell.Commands.ResolvePathCommand

nohwnd avatar Mar 16 '15 15:03 nohwnd