I had to limit $maxWorkers to 1 to deal with my badly equiped database instance, else all but the first database upgrade failed. However, when doing so, I learned that e.g. Where-Object returns an array only if there are more than one match. But it returns an OBJECT if there is just one match. So statements like ($active.Count -lt $maxWorkers) don't work in that case.
As I had trouble with that in the UpgradeContent function, I have listed only the occurrences in this function, which may require a wrapping of the statements in @(...). There are more lines where this approach may make sense.
Besides that: it would be great, if maxWorkers is a parameter of the script (can default to 4). I have never seen a trustable calculation how many upgrades can be done in parallel, so I wonder if the limitiation can actually be calculated (or tested).
Hi Jeff, a happy New Year!
I had to limit $maxWorkers to 1 to deal with my badly equiped database instance, else all but the first database upgrade failed. However, when doing so, I learned that e.g. Where-Object returns an array only if there are more than one match. But it returns an OBJECT if there is just one match. So statements like ($active.Count -lt $maxWorkers) don't work in that case.
The best solution I found here: https://stackoverflow.com/questions/11107428/how-can-i-force-powershell-to-return-an-array-when-a-call-only-returns-one-objec and states that one should wrap the command in @(...) to enforce getting an array (an empty, one-element or multi-element array).
As I had trouble with that in the UpgradeContent function, I have listed only the occurrences in this function, which may require a wrapping of the statements in @(...). There are more lines where this approach may make sense.
https://github.com/spjeff/sppatchify/blob/bb77918cc823d016abdfbdfcc6b904468336efe2/SPPatchify.ps1#L982 https://github.com/spjeff/sppatchify/blob/bb77918cc823d016abdfbdfcc6b904468336efe2/SPPatchify.ps1#L1004 https://github.com/spjeff/sppatchify/blob/bb77918cc823d016abdfbdfcc6b904468336efe2/SPPatchify.ps1#L1055 https://github.com/spjeff/sppatchify/blob/bb77918cc823d016abdfbdfcc6b904468336efe2/SPPatchify.ps1#L1068
Besides that: it would be great, if maxWorkers is a parameter of the script (can default to 4). I have never seen a trustable calculation how many upgrades can be done in parallel, so I wonder if the limitiation can actually be calculated (or tested).
Regards Malte