'Create a new WMI connection'

def get_connection(self):

    self.logger.debug(u'Connecting    to    WMI    server    (host={host},    namespace={namespace},    provider={provider},    username={username}).'.format(host=self.host, namespace=self.namespace, provider=self.provider, username=self.username))
    additional_args = []
    pythoncom.CoInitialize()
    if (self.provider != ProviderArchitecture.DEFAULT):
        context = Dispatch('WbemScripting.SWbemNamedValueSet')
        context.Add('__ProviderArchitecture', self.provider)
        additional_args = [None, '', 128, context]
    locator = Dispatch('WbemScripting.SWbemLocator')
    connection = locator.ConnectServer(self.host, self.namespace, self.username, self.password, *additional_args)
    return connection
