Multiple line or array to one line (Example: Windows Version)

Aus Wiki-WebPerfect
Version vom 11. Februar 2021, 14:02 Uhr von Admin (Diskussion | Beiträge)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

Multiple line/array to one line

Multiple line/array

 CurrentMajorVersionNumber","CurrentMinorVersionNumber","CurrentBuildNumber","ReleaseId","UBR" | foreach {(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").$_}

Output

10
0
14393
1607
2156

Format Multiple line/array to one line (with "." between each number) - Display Windows Version (incl. Patchlevel)

 ("CurrentMajorVersionNumber","CurrentMinorVersionNumber","CurrentBuildNumber","ReleaseId","UBR" | foreach {(Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion").$_}) -join "."

Output

10.0.14393.1607.2156

-> This only works on Server 2016 or higher.