Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
I'm writing a PowerShell Cmdlet in C# which should import users from the Active Directory into our Solution.
The idea is to search for AD-Users via the "Get-ADUser"-Cmdlet and use the output for our own Cmdlet. Example call:

Get-ADUser -Filter * | Select -First 5 | Add-SolutionUser

The problem is: Our cmdlet is called 5 times.
For the performance it would be much better to receive all five users in the pipeline at once.

How to do this?

The parameter of our "Add-SolutionUser" cmdlet is defined like that:
C#
[Parameter(Position = 0, Mandatory = true, HelpMessage = "List of AD users to import.", ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public object[] ADUserList { get; set; }


Thanks a lot.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900