An operator-valued Lyapunov theorem