pipe not working

by gsandtner at 2012-09-05 02:45:41

I want all allowed Cmdlets for a given Rolegroup.
So I tried:
PS C:> (Get-Rolegroup "help desk").roles | Get-ManagementRoleEntry $* | Group-Object name
Cannot process argument transformation on parameter 'Identity'. Cannot convert value "*" to type "Microsoft.E
xchange.Configuration.Tasks.RoleEntryIdParameter". Error: "Das Format des in den Parameter Microsoft.Exchange.
Configuration.Tasks.RoleEntryIdParameter eingegebenen Werts ist ungültig. Prüfen Sie den Wert, und versuchen S
ie es erneut.
Parameter name: identity"
+ CategoryInfo : InvalidData: (:slight_smile: [Get-ManagementRoleEntry], ParameterBindin…mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-ManagementRoleEntry


Next attempt:
PS C:> (Get-Rolegroup "help desk").roles | ForEach-Object {Get-ManagementRoleEntry $
*} | Group-Object name

Count Name Group
----- ---- -----
1 Set-HybridConfiguration {User Options}
1 New-HybridConfiguration {User Options}
2 Set-ADServerSettings {User Options, View-Only Recipients}

This is the expected result.
But why is the additional ForEach-Object required ?
by Techibee.Author at 2012-09-05 03:14:38
I believe Get-ManagementRoleEntry cmdlet is not properly coded. That means it is not having one of ValueFromPipeline, ValueFromPipelineByPropertyName parameters set for Identity arguments. Still this is just a guess. For a cmdlet to have the ability to process inputs from pipe line, it should have aforementioned properties set and on top of it, the actual code should have begin{} process {} end {} blocks.

Wait and see what the big minds in this forum says about this. I am still a learner :slight_smile:
by poshoholic at 2012-09-05 05:19:33
$_ is a special variable that is only available via script blocks used in a pipeline. Referencing that variable outside of a script block will never work. That means you either need to use ForEach-Object or you need to use something referred to as ScriptBlock parameters (which should not be confused with parameters that are of type ScriptBlock). You can read more about ScriptBlock parameters here:


I don’t have the Exchange 2010 cmdlets handy, but if the Identity parameter is configured for pipeline input you may be able to do this instead of using ForEach-Object:

(Get-RoleGroup "help desk").roles | Get-ManagementRoleEntry {"$_*"} | Group-Object name
That will only work if the Identity parameter is not of type ScriptBlock and if it is configured with either the ValueFromPipeline or the ValueFromPipelineByPropertyName attribute. Otherwise the parameter doesn’t "know" anything about the pipeline or what to do with it, in which case ForEach-Object comes to the rescue.
by gsandtner at 2012-09-05 23:02:11
Very helpfull, many thanks.