To avoid a lot of wasted time and frustration you might start with learning the very basics of Powershell. The free video course from Microsoft Virtiual Academy - Getting Started with Powershell might be good starting point for you.
I thinks it is beyond the scope of this forum to teach you how to do scripting with Powershell.
Something to get you started with below. I don’t know what are the community rules here regarding promoting your own content, but check my LinkedIn profile and you will find a link to a course I have published. One of the sections is creating a server inventory which covers this topic in a lot more details.
$servers = Get-Content .\servers.txt # Read a list of servers
$tempCol = @() # Creates an empty array
$ScriptBlock = {
$myObj = "" | Select-Object Hostname, Services, Software, Services2 # Creates a temporary object to store data
$myObj.Hostname = Write-Output $env:COMPUTERNAME # Collect computername
$myObj.Services = get-service # Create a list of services
$myObj.Software = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate # Create a list of software installed
$myObj.Services2 = Get-WmiObject win32_service |ft name, state, startname # Create a list of services again for some reason
return $myObj # return the object
}
$tempCol += Invoke-Command -ComputerName $servers -ScriptBlock $ScriptBlock | Select Hostname, Services, Software, Services2 # Invoke command remotely on all servers and add results to an array
Write-Output $tempCol ## Ouptut the contents of the array