I don't know why these commands resulting in extra lines, looks like 2 or 3 lines after the OS caption. How do I rid of the lines after the OS caption?
cls
(Get-WmiObject -class Win32_OperatingSystem -ComputerName server1).Caption
Get-WmiObject -Class Win32_OperatingSystem -ComputerName server1 | Select-Object -Property BuildNumber,BuildType,OSType,ServicePackMajorVersion,ServicePackMinorVersion
Result output:
Microsoft Windows Server 2012 R2 Standard
BuildNumber : 9600 BuildType : Multiprocessor Free OSType : 18 ServicePackMajorVersion : 0 ServicePackMinorVersion : 0