Optimizing the utilization of PowerShell processing through multi-threading techniques such as runspaces and multiple jobs can be done in several ways. These techniques can often be intricate and dem...
Amazing. Thank you. Could you save the initial result of the first Get-ConnectionInformation cmdlet to a variable for re-use? That way you don’t have to make another call to the cmdlet to get the path from the ModuleName property and that should improve performance further.
hi niehweunestukey Get-ConnectionInformation won't necessarily result in $null even if it is not connected to EXO. It will still give you some output, just that the connection state would be broken, expired or disconnected. See this -
And you will still be able to load Get-mailbox cmdlet or any other EXO commands in the same session but when executed, you would get an error that you are not connected to EXO.
Another approach would be to check connection state, like this:
if ((Get-ConnectionInformation).state -ne "Connected") {
Connect-ExchangeOnline
} Else {
Write-Host "Connected to EXO"
}
but in case of Parallelism, you would have numerous connections and it will be hard to figure out which thread has an active connection. See this:
Although not impossible, but then it's not easy to code for a beginner. And also the goal of parallelism would be to get bulk operations completed faster.