The snippet above raises an error as the command attempts to bind the input pipeline to credential parameters.
Starting discovery in 1 files.
Discovering in C:\Development\cp-powershell-imagehelper\module.tests.ps1.
Found 1 tests. 26ms
Discovery finished in 33ms.
Running tests from 'C:\Development\cp-powershell-imagehelper\module.tests.ps1'
Describing Some tests
PesterMock_f491b2df-48aa-450b-b9e6-f45bfd19fc8c: C:\Development\cp-powershell-imagehelper\module.psm1:3
Line |
3 | Get-EC2Volume
| ~~~~~~~~~~~~~
| Cannot process argument transformation on parameter 'NetworkCredential'. userName
PesterMock_f491b2df-48aa-450b-b9e6-f45bfd19fc8c: C:\Development\cp-powershell-imagehelper\module.psm1:3
Line |
3 | Get-EC2Volume
| ~~~~~~~~~~~~~
| Cannot process argument transformation on parameter 'NetworkCredential'. userName
[-] Should execute on a pipeline without failing 118ms (117ms|2ms)
Expected Get-EC2Volume to be called at least 1 times but was called 0 times
at Should -Invoke Get-EC2Volume, C:\Development\cp-powershell-imagehelper\module.tests.ps1:37
at <ScriptBlock>, C:\Development\cp-powershell-imagehelper\module.tests.ps1:37
Tests completed in 251ms
Tests Passed: 0, Failed: 1, Skipped: 0 NotRun: 0
Environment
Build Version: 4.0.6
OS Info: Windows 10
Build Environment: N/A
Targeted .NET Platform: N/A
Resolution
Remove ValueFromPipeline from Credential parameters.
We have noticed this issue has not recieved attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.
Description
When testing my code, and mocking Get-EC2Volume using Pester I expect to be able to supply an input pipeline for Get-EC2Volume.
Get-EC2Volume accepts by-value pipeline input for InstanceId, Credential, and NetworkCredential.
Pipeline input for InstanceId is somewhat expected. By-Value pipeline input for credential parameters is not.
PowerShell will attempt to bind all parameters accepting by-value input which causes a parameter binding failure.
Reproduction Steps
The snippet above raises an error as the command attempts to bind the input pipeline to credential parameters.
Environment
Resolution
Remove ValueFromPipeline from Credential parameters.
This is a :bug: bug-report