We present an explicit description of the cohomology spaces of any finitely generated virtually nilpotent group with (non-trivial) coefficients in a finite-dimensional real vector space. The input of the algorithm we develop to compute these cohomology spaces consists on the one hand of the module structure, and on the other hand of a polynomial crystallographic action of the group. Since. any virtually nilpotent group admits such an action (which can be constructed algorithmically) our methods apply to all finitely generated virtually nilpotent groups. As an application of our results, we present explicit formulas for the dimension of the cohomology spaces of a virtually abelian group with coefficients in a finite-dimensional real vector space, equipped with a particular kind of module structure.