Check if the windows credentials are valid

def validate_windows_cred(host,
                          username='Administrator',
                          password=None,
                          retries=10,
                          retry_delay=1):
    '''
    Check if the windows credentials are valid
    '''
    for i in range(retries):
        ret_code = 1
        try:
            stdout, stderr, ret_code = run_psexec_command(
                'cmd.exe', '/c hostname', host, username, password, port=445
            )
        except Exception as exc:
            log.exception("Exceoption while executing psexec")
        if ret_code == 0:
            break
        time.sleep(retry_delay)
    return ret_code == 0