Script request - SQL server inventory

I’d like to know what version of sql and to what patch level my servers are running.

So the output would be something like

SERVER1 Windows 2012r2 SQL 2014 SP3

SERVER2 Windows 2016 SQL 2017 cu3

I have the list of servers in a csv file and would like to use that as the source for the servers the script looks for.

Can anyone help with a script for this?

Did you attempt to search for this? “powershell get sql version” provide many results. If you have SQL Management installed on your system, you can use this:

https://docs.microsoft.com/en-us/powershell/module/sqlserver/get-sqlinstance?view=sqlserver-ps

If not, then search and there are registry and WMI solutions.