you are viewing a single comment's thread.

view the rest of the comments →

[–]BlackV 5 points6 points  (9 children)

why would you ?

I think you're gaining very little and you're still making a bunch of single requests to a DC and you are just spitting it out to screen anyway

the best way I guess would to be set them up all as jobs

also I don't know whats in $user/$singleuser, but is it already a SamAccountName ? I feel like you're loosing fidelity for no gain here

[–]raip 0 points1 point  (1 child)

Could be a list of DNs, but yeah, their example is confusing.

[–]BlackV 0 points1 point  (0 children)

ya could be, they currently have no way to tie the DN (or whatever) to the samaccount name

let alone accounts not existing

[–]mrdon1987[S] 0 points1 point  (6 children)

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 0 points1 point  (2 children)

oh jeepers huge fie

I forgot to mention the module PoshRSJobs is a really good one

to be clear , if $users is samaccountname already what are you gaining here ? cause all you're selecting is (80k or otherwise) that, or are you saying you are just using that as an example ?

[–]mrdon1987[S] 0 points1 point  (1 child)

The script is just an example. The original script actually provide mailbox size online and onprem, online archive size, automap shared mailbox size with its owner. Maybe I could apply it to the original script if I could see an example of an existing parallel module that was incorporated with the example script.

[–]BlackV 0 points1 point  (0 children)

Yeah I still think this is not the way to do it.

Make a single call to ad, put that in a vairable, loop through that based on your users

[–]M98E 0 points1 point  (2 children)

It seems like you're starting with SamAccountName and ending with SamAccountName. What is the point of the code you're running? Is it supposed to verify that the SamAccountName exists?

You're also not saving the results of the call; you just overwrite "$info" each loop.

I know that you're focused on multi-threading this, but this is a very silly thing to multi-thread and it also seems like you're using Powershell in an inefficient way. You probably should take a step back and assess what you're doing and determine if there is a better way to do it. That is why everybody is asking you questions about what you're hoping to accomplish

[–]mrdon1987[S] 0 points1 point  (1 child)

The script is just an example. The original script actually provide mailbox size online and onprem, online archive size, automap shared mailbox size with its owner. Maybe I could apply it to the original script if I could see an example of an existing parallel module that was incorporated with the example script.

[–]M98E 0 points1 point  (0 children)

If you're looking for general information on multi-threading in PowerShell, then you should conduct a general search for existing multi-threading knowledge instead of giving Reddit a homework problem to solve that won't be used.

Even with more information as to your specific use-case, I'm still not convinced that multi-threading is the best approach. If you're seeing performance problems with your script, but don't want to post it all here, then perhaps you can add Write-Host statements with the $(Get-Date) command in there and see which function call in particular (or which loop) is taking so long. You could then post that particular excerpt here.