(self, application_arguments=None)
Opens the runspace pool, this step must be called before it can be
        used.

        :param application_arguments: A dictionary of variables to set for the
            runspace host. These can then be accessed in a PowerShell instance
            of the runspace with $PSSenderInfo.ApplicationArguments
Opens the runspace pool, this step must be called before it can be
        used.
Opens the runspace pool this step must be called before it can be used .
def open(self, application_arguments=None):
        """
        Opens the runspace pool, this step must be called before it can be
        used.

        :param application_arguments: A dictionary of variables to set for the
            runspace host. These can then be accessed in a PowerShell instance
            of the runspace with $PSSenderInfo.ApplicationArguments
        """
        log.info("Opening a new Runspace Pool on remote host")
        if self.state == RunspacePoolState.OPENED:
            return
        if self.state != RunspacePoolState.BEFORE_OPEN:
            raise InvalidRunspacePoolStateError(
                self.state, RunspacePoolState.BEFORE_OPEN,
                "open a new Runspace Pool"
            )

        session_capability = SessionCapability(PROTOCOL_VERSION, PS_VERSION,
                                               SERIALIZATION_VERSION)
        init_runspace_pool = InitRunspacePool(
            self.min_runspaces, self.max_runspaces,
            PSThreadOptions(value=self.thread_options),
            ApartmentState(value=self.apartment_state),
            HostInfo(host=self.host),
            application_arguments
        )
        msgs = [session_capability, init_runspace_pool]
        fragments = self._fragmenter.fragment_multiple(msgs, self.id)

        open_content = ET.Element(
            "creationXml", xmlns="http://schemas.microsoft.com/powershell"
        )
        open_content.text = base64.b64encode(fragments.pop(0)).decode('utf-8')

        options = OptionSet()
        options.add_option("protocolversion", PROTOCOL_VERSION,
                           {"MustComply": "true"})
        self.shell.open(options, open_content)
        self.state = RunspacePoolState.NEGOTIATION_SENT

        responses = []
        while self.state == RunspacePoolState.NEGOTIATION_SENT:
            responses.extend(self._receive())
def open ( self , application_arguments = None ) : log . info ( "Opening a new Runspace Pool on remote host" ) if self . state == RunspacePoolState . OPENED : return if self . state != RunspacePoolState . BEFORE_OPEN : raise InvalidRunspacePoolStateError ( self . state , RunspacePoolState . BEFORE_OPEN , "open a new Runspace Pool" ) session_capability = SessionCapability ( PROTOCOL_VERSION , PS_VERSION , SERIALIZATION_VERSION ) init_runspace_pool = InitRunspacePool ( self . min_runspaces , self . max_runspaces , PSThreadOptions ( value = self . thread_options ) , ApartmentState ( value = self . apartment_state ) , HostInfo ( host = self . host ) , application_arguments ) msgs = [ session_capability , init_runspace_pool ] fragments = self . _fragmenter . fragment_multiple ( msgs , self . id ) open_content = ET . Element ( "creationXml" , xmlns = "http://schemas.microsoft.com/powershell" ) open_content . text = base64 . b64encode ( fragments . pop ( 0 ) ) . decode ( 'utf-8' ) options = OptionSet ( ) options . add_option ( "protocolversion" , PROTOCOL_VERSION , { "MustComply" : "true" } ) self . shell . open ( options , open_content ) self . state = RunspacePoolState . NEGOTIATION_SENT responses = [ ] while self . state == RunspacePoolState . NEGOTIATION_SENT : responses . extend ( self . _receive ( ) )