How to connect each SQL instance to get SQL server version updated into the temp table?
Just use dbatools - Get-DbaCmsRegServerGroup


  Gets list of Server Groups objects stored in SQL Server Central Management Server (CMS).


If you have multiple servers to connect, you can use foreach to loop through each servers and store the result into a variable.

You can even write to a database using ConvertTo-DbaDataTable and Write-DbaDataTable