Normally , I can catch values beginning with Windows Server like below script. But I want to get version number for operating systems as well.
Windows Embedded
Windows XP
Windows 7
Windows 10
Windows Server® 2008 Standard
Windows Server® 2008 Enterprise
So , it will be only 7 ,XP , 10 , Embedded , 2008 inside version variable.
Script :
$server = Get-ADComputer -Filter "Name -eq '$computer'" -Properties OperatingSystem -ErrorAction SilentlyContinue
$version = ([regex]'Windows Server (\d+)').Match($server.OperatingSystem).Groups[1].Value
®symbol, tryWindows Server\D+(\w+)to match it and spaces, too.\wwill match letters and digits (and_, too).Windows(?: Server)?[^\w\r\n]+(\w+)regex101.com/r/iRhmJT/1