You may use the below commands to extract a list of computer accounts as well as Operating system and Service pack levels:
Open Powershell and then run the below cmd to import AD module:
Once module is imported run the below command to extract a list of the Computer accounts in AD as well as their Operating system and service pack level:
Get-ADComputer -Filter * -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap –Auto >ComputerExtract.txt
This will create a text file with the output.