Why the following method does not have an overload which accepts a RunspaceConnectionInfo (to specify the remote server info) as well as a InitialSessionState?
Full Context:
I am building a RunspacePoolCache, that would cache remote RunspacePools created using RunspaceFactory. Cache is keyed on remote server info. Till the pool's RunspacePoolStateInfo.State is Open, the same RunspacePool would be used for executing Powershell scripts on same remote server. (Shameless plug: Will this work?)
Now, I want to add a set of Powershell snap-ins that are common to the created RunspacePool. Adding the snap-ins within the executed script is at times leading to the following exception:
An item with the same key has already been added
This is happening even when I do the following in the Powershell script (but less often):
if ((Get-PSSnapin | ? { $_.Name -eq 'VeeamPSSnapIn' }) -eq $null) {
Add-PsSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
}
That is where I am trying to load the snap-ins via InitialSessionState. But from the set of methods provided, it seems InitialSessionState can be specified only while creating local RunspacePools.