{"action":"created","issue":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/8516","repository_url":"https://api.github.com/repos/PowerShell/PowerShell","labels_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/8516/labels{/name}","comments_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/8516/comments","events_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/8516/events","html_url":"https://github.com/PowerShell/PowerShell/issues/8516","id":393615042,"node_id":"MDU6SXNzdWUzOTM2MTUwNDI=","number":8516,"title":"PowerShell ValueFromPipeline parameter brakes ParameterSet selection","user":{"login":"ili101","id":6960531,"node_id":"MDQ6VXNlcjY5NjA1MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/6960531?v=4","gravatar_id":"","url":"https://api.github.com/users/ili101","html_url":"https://github.com/ili101","followers_url":"https://api.github.com/users/ili101/followers","following_url":"https://api.github.com/users/ili101/following{/other_user}","gists_url":"https://api.github.com/users/ili101/gists{/gist_id}","starred_url":"https://api.github.com/users/ili101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ili101/subscriptions","organizations_url":"https://api.github.com/users/ili101/orgs","repos_url":"https://api.github.com/users/ili101/repos","events_url":"https://api.github.com/users/ili101/events{/privacy}","received_events_url":"https://api.github.com/users/ili101/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-21T23:09:59Z","updated_at":"2018-12-22T23:11:03Z","closed_at":null,"author_association":"NONE","body":"# Steps to reproduce\r\n```PowerShell\r\nfunction Export-Excel {\r\n    [CmdletBinding(DefaultParameterSetName = 'Default')]\r\n    Param(\r\n        [Parameter(ParameterSetName = \"Default\")]\r\n        [Parameter(ParameterSetName = \"AutoFilter\")]\r\n        [String]$Path,\r\n\r\n        [Parameter(Mandatory = $true, ParameterSetName = \"PackageDefault\")]\r\n        [Parameter(Mandatory = $true, ParameterSetName = \"PackageAutoFilter\")]\r\n        $ExcelPackage,\r\n\r\n        [Parameter(ValueFromPipeline = $true)]\r\n        $TargetData,\r\n\r\n        [Parameter(Mandatory = $true, ParameterSetName = 'AutoFilter')]\r\n        [Parameter(Mandatory = $true, ParameterSetName = 'PackageAutoFilter')]\r\n        $AutoFilter,\r\n\r\n        [Parameter(ParameterSetName = 'Default')]#, ValueFromPipelineByPropertyName)]\r\n        [Parameter(ParameterSetName = 'PackageDefault')]#, ValueFromPipelineByPropertyName)]\r\n        [String]$TableName,\r\n        [Parameter(ParameterSetName = 'Default')]\r\n        [Parameter(ParameterSetName = 'PackageDefault')]\r\n        [Switch]$Table,\r\n        [Parameter(ParameterSetName = 'Default')]\r\n        [Parameter(ParameterSetName = 'PackageDefault')]\r\n        $TableStyle = 'Medium6'\r\n    )\r\n    \"ParameterSet: \" + $PSCmdlet.ParameterSetName\r\n}\r\n# Works\r\nExport-Excel -ExcelPackage 5 -TargetData 5\r\nExport-Excel -ExcelPackage 5\r\n# Prompt for \"AutoFilter:\"\r\n5 | Export-Excel -ExcelPackage 5\r\n```\r\n\r\n# Expected behavior\r\n```none\r\nParameterSet: PackageDefault\r\nParameterSet: PackageDefault\r\nParameterSet: PackageDefault\r\n```\r\n\r\n# Actual behavior\r\n```none\r\nParameterSet: PackageDefault\r\nParameterSet: PackageDefault\r\n\r\ncmdlet Export-Excel at command pipeline position 1\r\nSupply values for the following parameters:\r\nAutoFilter:\r\n```\r\n\r\nWhen not passing $ExcelPackage or passing it as a parameter ParameterSet PackageDefault is selected, but when providing it from Pipeline it asks for $AutoFilter from the wrong ParameterSet.\r\n\r\nTested on 5.1 and 6.2.0-preview.3\r\n\r\nI also tried to workaround this by providing multiple DefaultParameterSetName hoping it will evaluate them in order but looks like it's not a thing, Feature request?\r\n```PowerShell\r\n[CmdletBinding(DefaultParameterSetName = 'Default,', 'PackageDefault')]\r\n```\r\n`Cannot find an overload for \".ctor\" and the argument count: \"1\".`"},"comment":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/comments/449603236","html_url":"https://github.com/PowerShell/PowerShell/issues/8516#issuecomment-449603236","issue_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/8516","id":449603236,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTYwMzIzNg==","user":{"login":"ili101","id":6960531,"node_id":"MDQ6VXNlcjY5NjA1MzE=","avatar_url":"https://avatars1.githubusercontent.com/u/6960531?v=4","gravatar_id":"","url":"https://api.github.com/users/ili101","html_url":"https://github.com/ili101","followers_url":"https://api.github.com/users/ili101/followers","following_url":"https://api.github.com/users/ili101/following{/other_user}","gists_url":"https://api.github.com/users/ili101/gists{/gist_id}","starred_url":"https://api.github.com/users/ili101/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ili101/subscriptions","organizations_url":"https://api.github.com/users/ili101/orgs","repos_url":"https://api.github.com/users/ili101/repos","events_url":"https://api.github.com/users/ili101/events{/privacy}","received_events_url":"https://api.github.com/users/ili101/received_events","type":"User","site_admin":false},"created_at":"2018-12-22T23:11:03Z","updated_at":"2018-12-22T23:11:03Z","author_association":"NONE","body":"Apparently adding `ValueFromPipelineByPropertyName` to `$AutoFilter` workaround this problem (I have no idea why though, It doesn't make sense)\r\n``` PowerShell\r\n[Parameter(Mandatory = $true, ParameterSetName = 'AutoFilter', ValueFromPipelineByPropertyName)]\r\n[Parameter(Mandatory = $true, ParameterSetName = 'PackageAutoFilter', ValueFromPipelineByPropertyName)]\r\n$AutoFilter,\r\n```"}}
{"actor":{"display_login":"ili101"}}