I do not know about general C*-algebras, but the statement is true for complex matrices.
Uniqueness: Assume b = xax. Then a1/2ba1/2 = a1/2xaxa1/2 = (a1/2xa1/2)2, which implies that a1/2xa1/2 = (a1/2ba1/2)1/2. Since a is invertible, x must be a−1/2(a1/2ba1/2)1/2a−1/2.
Existence: It is easy to check that x = a−1/2(a1/2ba1/2)1/2a−1/2$x=\sqrt{a}^{-1}\sqrt{\sqrt{a}\hspace{.15cm}b\sqrt{a}\quad}\sqrt{a}^{-1}$ satisfies the condition.
I do not think that anything in this argument depends on the fact that we are considering matrices, but let me avoid claiming things about the subject which I do not know well.

