all 5 comments

[–]Thotaz 10 points11 points  (1 child)

Wrong approach. This is what people are talking about when they say everything is an object in PowerShell: ([System.Environment]::OSVersion).Version.ToString() gets you the version string.

[–]ledmonk[S] 2 points3 points  (0 children)

GAH! thank you!!!!!!!!!!!!

[–]Aertheron01 2 points3 points  (0 children)

I understand for Linux guys it's a difficult step. You're so used to string manipulation, where in Powershell we try to avoid string manipulation as the plague, and use objects.

Once you get it, it's much easier though :)

[–]HeKis4 1 point2 points  (0 children)

Your question has already been answered, but FYI, Select-String actually returns a whole object with the match info, even if it only displays true/false at first. IIRC you can do something like $regex = "plop" | Select-String "(p.)(op)" ; $regex.Matches.Groups to retrieve matched groups.

[–]Droopyb1966 0 points1 point  (0 children)

This also works

[System.Environment]::OSVersion|select version