Open robrtitus opened 7 years ago
My only concern with this is that by add the current host to the runspacepool creation, all of the streams (Verbose, Debug, etc...) will leak to the current console instead of staying hidden in their runspace. I'd be open to adding a parameter such as -UseCurrentPSHost or something similar and then adding this as a feature.
@robrtitus
I'm not an Azure expert, I just checked the doc of Get-AzureRMVM
, it seems that it can go with the param -DefaultProfile
which might contain Azure crendentials.
https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/get-azurermvm?view=azurermps-5.4.0#optional-parameters
If so, you can connect to Azure before PoshRSJob, and passe the connection profile by Start-RSJob -VariablesToImport $azureProfile
:
I'm not sure it works, it's just an idea.
This allows passing open connections through to the threads. For example: without this additional code running Get-AzureRMVM would require running Login-AzureRMAccount on each thread. With the addition of this code you only need to run Login-AzureRMAccount outside the scope of the Start-RSJob cmdlet one time and not in each thread.
Changes proposed in this pull request:
How to test this code:
Has been tested on (remove any that don't apply):