Existence of a certain finite $2-$group Is there a finite non-abelian  $2-$group $P$ of order $2^n;  n\geq 4$ such that $\frac{P}{\langle x \rangle}\cong \Bbb{Z}_2\times\Bbb{Z}_{2^{n-2}}$ for $x\in Z(P)$ and $\lvert x\rvert =2$? ($\lvert x \rvert$ means the order of the element $x$)
 A: Here is a complete classification of such (nonabelian) groups.
Let $A_n$ be the cyclic group of order $2^{n-1}$. Then you have a group $P$ such that $P/P'\cong A_2\times A_{n-1}$. The preimage in $P$ of this $A_{n-1}$ is either $A_n$ or the group $B_n\cong A_2\times A_{n-1}$.  Either way, $P$ is a cyclic extension of one of these.
If it is an extension of $A_n$, there is an automorphism of order 2 - call it $\phi$ - such that $\phi^2\equiv id$. Since $P/\langle x\rangle$ is abelian, $\phi$ must send $a\in A_n$ to $xa$.  Now $\phi^2\in A_n$ has to be a non-generator, so we can pick an element $y\in A_n$ such that $y^2=\phi^2$. Then $\phi y^{-1}$ has the same effect on $A_n$, and squares to $1$.  In other words, your $P$ is a split extension, the group $A_{n}\rtimes A_2$.
If it is an extension of $B_n$, again $\phi$ must send $b\in A_{n-1}$ to $xb$, where $B=\langle x\rangle\times A_{n-1}$. Now similar reasoning shows $\phi^2$ is either the identity (so that $P$ is $B_n\rtimes A_2$), or it is $x$, so that $P$ is $A_3\rtimes A_{n-1}$.
These are all possible groups.
I am leaving out details, but they can easily be filled in. In particular, filling in my arguments will tell you exactly how these semidirect products "act".
A: Apologies to @SteveD I am very sorry, in a previous version of this post I had claimed that SteveD's classification was incomplete, whereas it was just me having failed to read his post accurately.
Consider a group $P$ as in the question. $\Phi(P)$ is spanned by the squares of elements of $P$. Take $a, b \in P$. Since $P' = \langle x \rangle$, we will have $[a, b] = x^{i}$ for some $i$.  Now we have $[a^{2}, b] = [a, b]^{a} [a, b] = x^{i} x^{i} = 1$. So $\Phi(P) \le Z(P)$. Note that $P/\Phi(P)$ is a Klein $4$-group, as $P$ is $2$-generated. So if $H$ is a maximal subgroup of $P$, then $H/\Phi(P) = P/\Phi(P)$ is cyclic (of order $2$), so $H$ is abelian.
So $P$ is what is called a minimal non-abelian $2$-group, that is, all of its proper subgroups are abelian. (Groups of the form given in the question are a proper subclass of that of minimal non-abelian $2$-groups.) Minimal non-abelian $p$-groups have been classified long ago by Rédei. The first page of this article is freely accessible and reports the classification, which for $p = 2$ and $n \ge 4$ reads


*

*$\Bbb{Z}_{2^{s}} \rtimes \Bbb{Z}_{2^{t}}$, of order $2^{s+t}$, with a generator $b$ of the second group acting on a generator $a$ of the first one by $[a, b] = 2^{s-1}$. Here $s \ge 2, t \ge 1$.

*$\langle a, b, c : a^{2^{s}} = b^{2^{t}} = c^{2} = 1, [a,c] = [b,c] = 1, [a, b]=c\rangle$ of order $2^{s+t+1}$. Here $s, t \ge 1$ and $s + t \ge 3$. (This follows in this case from the assumption $n = s + t + 1 \ge 4$.)


If you allow $n = 3$, then there's also the quaternion group of order $8$.
The groups asked for in the question occur in the first case for $t = 1$ or $s = 2$, and in the second case for $s = 1$ or $t = 1$.
With hindsight, Rédei's theorem is not difficult to prove.
