Suppose $M$ is a countable transitive model of some fragment of $\mathbf{ZFC}$, $\mathbb{P}\in M$ is a forcing notion and $G, H$ are $\mathbb{P}$-generic such that $M[G]=M[H]$. Does it then follow that there is some automorphism $\pi:\mathbb{P}\longrightarrow\mathbb{P}$ such that $\pi\in M$ and $\pi[G]=H$?

If the answer is no, are there natural restrictions one could impose on $\mathbb{P}$ (maybe apart from $\mathbb{P}$ being finite) such that the above sentence holds?