I need to convert Get-Mailbox | Select-Object -index (0..10) to C# code, but it give me the follow error,
Parameter set cannot be resolved using the specified named parameters. at System.Management.Automation.CmdletParameterBinderController.ThrowAmbiguousParameterSetException(UInt32 parameterSetFlags, MergedCommandParameterMetadata bindableParameters)
My code is like the follow: I just want to know how to convert indices to object, I also tried CommandParameters but with no lucky, I do NOT want to use syntax like "-index first 5", I have my reason for this.
Command exchangeCommand = new Command("Get-Mailbox"); Command selectCommand = new Command("Select-Object"); int [] indexParam = new int[] {0, 1, 2, 3, 4}; selectCommand.Parameters.Add("index", indexParam); pipeLine.Commands.Add(exchangeCommand); pipeLine.Commands.Add(selectCommand); Collection<PSObject> results = pipeLine.Invoke();