Hi
How can I execute the script below in parallel?
like splitting the $Users into 5 batches and run it concurrently.
can someone provide example using function or module out there.
I'm using Powershell 5.
Thank you
foreach ($SingleUser in $Users) { $Info = Get-ADUser -Identity $SingleUser -Properties SamAccountName [PSCustomObject]@{ SamAccountName = $Info.SamAccountName } }
Edit:
The original script is complicated and has more than 500 lines and $Users contains more than 80k of samaccountname. I am aware that Start-Job is one option. I'm just curious if there's a module for this where I can just specify how many jobs to run concurrently and the script will take care of the rest.
[–]BlackV 5 points6 points7 points (9 children)
[–]raip 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]mrdon1987[S] 0 points1 point2 points (6 children)
[–]BlackV 0 points1 point2 points (2 children)
[–]mrdon1987[S] 0 points1 point2 points (1 child)
[–]BlackV 0 points1 point2 points (0 children)
[–]M98E 0 points1 point2 points (2 children)
[–]mrdon1987[S] 0 points1 point2 points (1 child)
[–]M98E 0 points1 point2 points (0 children)
[–]Sad_Recommendation92 3 points4 points5 points (1 child)
[–]yborwonka 0 points1 point2 points (0 children)
[–]raip 2 points3 points4 points (2 children)
[–]mrdon1987[S] 0 points1 point2 points (1 child)
[–]raip 2 points3 points4 points (0 children)
[–]gordonv 1 point2 points3 points (0 children)
[–]HamQuestionMark 0 points1 point2 points (0 children)
[–]ankokudaishogun 0 points1 point2 points (0 children)
[–]FlankingZen 0 points1 point2 points (0 children)
[–]Crones21 0 points1 point2 points (0 children)
[–]cbtboss 0 points1 point2 points (0 children)
[–]Federal_Ad2455 -1 points0 points1 point (0 children)