Exact relation between kernel and invertibility of a differential operator

Let’s assume we have a differential operator $D$ and a differential equation
begin{equation}
Df=j
end{equation}

What is the connection between invertibility, the kernel of the operator and the initial conditions we have to provide.

Example: Let’s look at the general Maxwell equation
begin{equation}
square A^{mu}-partial^{mu}left(partial_{nu} A^{nu}right)= j^{mu}
end{equation}

Fourier transformation yields
begin{equation}
left(-k^{2} eta^{mu nu}+k^{mu} k^{v}right) tilde{A}_{v}(k)=tilde{j}(k)^{mu}
end{equation}

On physics (https://physics.stackexchange.com/questions/640440/gauge-invariant-greens-function-for-electrodynamics) it was said that this equation is non invertible because the differential operator vanishes on $k_{nu}$. However fixing the gauge, i.e. imposing $partial_{nu} A^{nu}$ makes it invertible. This leads to the retarded and advanced potentials. What is the exact reason why this differential operator is non invertible. I thought it is because its kernel is not zero.

But looking at the equation
begin{equation}
square A^{mu}=j^{mu}
end{equation}

the operator $square$ also has nonzero kernel because it vanishes on harmonic functions. Nonetheless the equation above is invertible.

So when is a differential operator invertible and what has it to do with its kernel?