![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #11 (permalink) |
| | Re: Reliable way to get Windows Version? Maybe this, I can't test against Vista nor Server 2008: $servers = "Srv1","Srv2","WKS1" gwmi Win32_OperatingSystem -computer $servers | select CSName,Caption,CSDVersion,Version CSName Caption CSDVersion Version ------ ------- ---------- ------- Srv1 Microsoft(R) Windows(R) Server 2003 Standard x64 Edition Service Pack 2 5.2.3790 Srv2 Microsoft(R) Windows(R) Server 2003, Standard Edition Service Pack 2 5.2.3790 WKS1 Microsoft Windows XP Professional Service Pack 2 5.1.2600 ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Won't help - returns the exact same for Server 2008 and Vista with > SP1. (and has the same problem with XP x64 and Server 2003 SP1). And > doesn't give me edition so I can branch on features available. > > "Shay Levi" <no@xxxxxx> wrote in message > news:8766a94423a778ca5635947a6762@xxxxxx > Quote: >> You can also try the plain old DOS ver command: >> >> # on XP box >> PS> cmd /c ver >> Microsoft Windows XP [Version 5.1.2600] >> # on Win2003 server R2 x64 >> PS> cmd /c ver Microsoft Windows [Version 5.2.3790] >> # on Windows 2000 STD Server SP4 >> PS> cmd /c ver >> Microsoft Windows 2000 [Version 5.00.2195] >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> I need a way to determine what Windows version and edition a script >>> is running on. I can get the build number, that's trivial: >>> >>> $Build=(get-item 'HKLM:/Software/Microsoft/Windows >>> NT/CurrentVersion').getvalue('CurrentBuildNumber') >>> >>> But it doesn't much help when Windows Vista SP1 is 6001 and so is >>> Windows Server 2008. And also doesn't tell me which edition. The >>> ProductID: >>> >>> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows >>> NT/CurrentVersion').getvalue('ProductID') >>> >>> could probably do it, but I'm not at all sure what I'm looking at >>> there, and how to parse it for what's important. First, does anyone >>> know a reference that gives the relevant numbers for the various >>> editions of Windows. And second, could someone suggest a regex to >>> parse it into consituent parts? Or, alternately, does someone have a >>> better location to get the version and edition of Windows? >>> >>> Thanks, >>> |
My System Specs![]() |
| | #12 (permalink) |
| | Re: Reliable way to get Windows Version? BTW, if the machines are members of a domain, can you check what's in the "Operating System" tab when you double click a computer account in ADUC? ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Maybe this, I can't test against Vista nor Server 2008: > > $servers = "Srv1","Srv2","WKS1" > gwmi Win32_OperatingSystem -computer $servers | select > CSName,Caption,CSDVersion,Version > CSName Caption > CSDVersion > Version > ------ ------- > ---------- > ------- > Srv1 Microsoft(R) Windows(R) Server 2003 Standard x64 Edition > Service Pack > 2 5.2.3790 > Srv2 Microsoft(R) Windows(R) Server 2003, Standard Edition > Service Pack > 2 5.2.3790 > WKS1 Microsoft Windows XP Professional > Service Pack > 2 5.1.2600 > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com Quote: >> Won't help - returns the exact same for Server 2008 and Vista with >> SP1. (and has the same problem with XP x64 and Server 2003 SP1). And >> doesn't give me edition so I can branch on features available. >> >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a94423a778ca5635947a6762@xxxxxx Quote: >>> You can also try the plain old DOS ver command: >>> >>> # on XP box >>> PS> cmd /c ver >>> Microsoft Windows XP [Version 5.1.2600] >>> # on Win2003 server R2 x64 >>> PS> cmd /c ver Microsoft Windows [Version 5.2.3790] >>> # on Windows 2000 STD Server SP4 >>> PS> cmd /c ver >>> Microsoft Windows 2000 [Version 5.00.2195] >>> ----- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> I need a way to determine what Windows version and edition a script >>>> is running on. I can get the build number, that's trivial: >>>> >>>> $Build=(get-item 'HKLM:/Software/Microsoft/Windows >>>> NT/CurrentVersion').getvalue('CurrentBuildNumber') >>>> >>>> But it doesn't much help when Windows Vista SP1 is 6001 and so is >>>> Windows Server 2008. And also doesn't tell me which edition. The >>>> ProductID: >>>> >>>> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows >>>> NT/CurrentVersion').getvalue('ProductID') >>>> >>>> could probably do it, but I'm not at all sure what I'm looking at >>>> there, and how to parse it for what's important. First, does anyone >>>> know a reference that gives the relevant numbers for the various >>>> editions of Windows. And second, could someone suggest a regex to >>>> parse it into consituent parts? Or, alternately, does someone have >>>> a better location to get the version and edition of Windows? >>>> >>>> Thanks, >>>> |
My System Specs![]() |
| | #13 (permalink) |
| | Re: Reliable way to get Windows Version? Charlie Russel - MVP wrote: Quote: > Won't help - returns the exact same for Server 2008 and Vista with SP1. > (and has the same problem with XP x64 and Server 2003 SP1). And doesn't > give me edition so I can branch on features available. documented and can give you the feature level--at least for Vista & 2008 Server. http://msdn2.microsoft.com/en-us/lib...39(VS.85).aspx Looks like SuiteMask is similar, works with XP & 2003 but nothing earlier. Looks harder to work with though (you have to bitmask). Other than that, I think you're going to have to either make a table to parse the version #'s or parse the Caption property. -- Hal Rottenberg Blog: http://halr9000.com Webmaster, Psi (http://psi-im.org) Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
| | #14 (permalink) |
| | Re: Reliable way to get Windows Version? This is going to be parsed at logon. The good news is, I don't have to deal with anything before XP/2003. The bad news is, I need to know if it's SBS or Server 2k3 Standard or XP x64 - all of which are possible on this network. Win32_OperatingSystem has OperatingSystemSKU, but that's empty for pre-Vista. Hmmm. OK, let me go poke around a bit more. Thanks. I'm getting at some ways to do this, certainly. I may have to use multiple methods depending on what level OS I have, but that's doable. -- Charlie. http://msmvps.com/xperts64 http://mvp.support.microsoft.com/profile/charlie.russel "Shay Levi" <no@xxxxxx> wrote in message news:8766a94423b448ca56703968487c@xxxxxx Quote: > BTW, if the machines are members of a domain, can you check what's in the > "Operating System" tab when you double > click a computer account in ADUC? > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: >> Maybe this, I can't test against Vista nor Server 2008: >> >> $servers = "Srv1","Srv2","WKS1" >> gwmi Win32_OperatingSystem -computer $servers | select >> CSName,Caption,CSDVersion,Version >> CSName Caption >> CSDVersion >> Version >> ------ ------- >> ---------- >> ------- >> Srv1 Microsoft(R) Windows(R) Server 2003 Standard x64 Edition >> Service Pack >> 2 5.2.3790 >> Srv2 Microsoft(R) Windows(R) Server 2003, Standard Edition >> Service Pack >> 2 5.2.3790 >> WKS1 Microsoft Windows XP Professional >> Service Pack >> 2 5.1.2600 >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> Won't help - returns the exact same for Server 2008 and Vista with >>> SP1. (and has the same problem with XP x64 and Server 2003 SP1). And >>> doesn't give me edition so I can branch on features available. >>> >>> "Shay Levi" <no@xxxxxx> wrote in message >>> news:8766a94423a778ca5635947a6762@xxxxxx >>>> You can also try the plain old DOS ver command: >>>> >>>> # on XP box >>>> PS> cmd /c ver >>>> Microsoft Windows XP [Version 5.1.2600] >>>> # on Win2003 server R2 x64 >>>> PS> cmd /c ver Microsoft Windows [Version 5.2.3790] >>>> # on Windows 2000 STD Server SP4 >>>> PS> cmd /c ver >>>> Microsoft Windows 2000 [Version 5.00.2195] >>>> ----- >>>> Shay Levi >>>> $cript Fanatic >>>> http://scriptolog.blogspot.com >>>>> I need a way to determine what Windows version and edition a script >>>>> is running on. I can get the build number, that's trivial: >>>>> >>>>> $Build=(get-item 'HKLM:/Software/Microsoft/Windows >>>>> NT/CurrentVersion').getvalue('CurrentBuildNumber') >>>>> >>>>> But it doesn't much help when Windows Vista SP1 is 6001 and so is >>>>> Windows Server 2008. And also doesn't tell me which edition. The >>>>> ProductID: >>>>> >>>>> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows >>>>> NT/CurrentVersion').getvalue('ProductID') >>>>> >>>>> could probably do it, but I'm not at all sure what I'm looking at >>>>> there, and how to parse it for what's important. First, does anyone >>>>> know a reference that gives the relevant numbers for the various >>>>> editions of Windows. And second, could someone suggest a regex to >>>>> parse it into consituent parts? Or, alternately, does someone have >>>>> a better location to get the version and edition of Windows? >>>>> >>>>> Thanks, >>>>> > |
My System Specs![]() |
| | #15 (permalink) |
| | Re: Reliable way to get Windows Version? Yeah, looks like I'd have to bitmask on SuiteMask for XP/2003. Which is doable. Fortunately, I don't need to deal with anything earlier. -- Charlie. http://msmvps.com/xperts64 http://mvp.support.microsoft.com/profile/charlie.russel "Hal Rottenberg" <hal@xxxxxx> wrote in message news:Ow2t8JGiIHA.4536@xxxxxx Quote: > Charlie Russel - MVP wrote: Quote: >> Won't help - returns the exact same for Server 2008 and Vista with SP1. >> (and has the same problem with XP x64 and Server 2003 SP1). And doesn't >> give me edition so I can branch on features available. > Coming back to Win32_OperatingSystems, the OperatingSystemSKU property is > well documented and can give you the feature level--at least for Vista & > 2008 Server. > > http://msdn2.microsoft.com/en-us/lib...39(VS.85).aspx > > Looks like SuiteMask is similar, works with XP & 2003 but nothing earlier. > Looks harder to work with though (you have to bitmask). > > Other than that, I think you're going to have to either make a table to > parse the version #'s or parse the Caption property. > > -- > > Hal Rottenberg > Blog: http://halr9000.com > Webmaster, Psi (http://psi-im.org) > Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
| | #16 (permalink) |
| | Re: Reliable way to get Windows Version? Caption will give me that, too. And operatingsystemSKU will give me full and gory details in Vista/Server2k8, which should shortly be most of what I have to deal with. So, I should be good with a combination of buildnumber, caption, CSDVersion and operatingsystemSKU. Oh, and osarchitecture for 32/64bit. -- Charlie. http://msmvps.com/xperts64 http://mvp.support.microsoft.com/profile/charlie.russel "Andy Schneider" <andy@xxxxxx-powershell.com> wrote in message news:611A2B10-C19D-43B5-A427-4F5394105642@xxxxxx Quote: > How about gwmi win32_operatingsystem | select Name > > - From 2008 RTM > PS C:\Users\superandys> gwmi win32_operatingSystem | select name > > name > ---- > Microsoft® Windows Server® 2008 Enterprise > |C:\Windows|\Device\Harddisk0\Partition2 > > > > From Vista Ultimate > PS C:\Users\superandys> > > > PS 2 > gwmi win32_operatingSystem | Select Name > > Name > ---- > Microsoft® Windows VistaT Ultimate > |C:\Windows|\Device\Harddisk0\Partition1 > > > PS 3 > > > > > > "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message > news:FD2A2D4F-5746-4237-9E9B-B177780C81C8@xxxxxx Quote: >> No help - returns the same for any version of Vista with SP1 as it does >> for Server 2008 RTM. But a good way to get the build number, certainly. >> >> -- >> Charlie. >> http://msmvps.com/xperts64 >> http://mvp.support.microsoft.com/profile/charlie.russel >> >> >> "Andy Schneider" <andy@xxxxxx-powershell.com> wrote in message >> news:9265C697-5DE4-4C8E-BAD3-B8023214FA79@xxxxxx Quote: >>> get-wmiobject win32_operatingsystem >>> >>> This will give you BuildNumber and Version >>> >>> Andy >>> http://get-powershell.com >>> >>> >>> >>> >>> "Charlie Russel - MVP" <charlie@xxxxxx> wrote in >>> message news:6116302E-00CF-46C6-A17B-4F35EA5575C9@xxxxxx >>>>I need a way to determine what Windows version and edition a script is >>>>running on. I can get the build number, that's trivial: >>>> >>>> $Build=(get-item 'HKLM:/Software/Microsoft/Windows >>>> NT/CurrentVersion').getvalue('CurrentBuildNumber') >>>> >>>> But it doesn't much help when Windows Vista SP1 is 6001 and so is >>>> Windows Server 2008. And also doesn't tell me which edition. The >>>> ProductID: >>>> >>>> $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows >>>> NT/CurrentVersion').getvalue('ProductID') >>>> >>>> could probably do it, but I'm not at all sure what I'm looking at >>>> there, and how to parse it for what's important. First, does anyone >>>> know a reference that gives the relevant numbers for the various >>>> editions of Windows. And second, could someone suggest a regex to parse >>>> it into consituent parts? Or, alternately, does someone have a better >>>> location to get the version and edition of Windows? >>>> >>>> Thanks, >>>> >>>> -- >>>> Charlie. >>>> http://msmvps.com/xperts64 >>>> http://mvp.support.microsoft.com/profile/charlie.russel >>>> >>>> >>> |
My System Specs![]() |
| | #17 (permalink) |
| | Re: Reliable way to get Windows Version? Thanks, Jon, Shay, Hal and Andy. Very much appreciated. I've got a couple of ways to do what I need to do, based on what you gave me. For the moment, I'm going with a combination of Win32_OperatingSystem properties, including BuildNumber, Caption, CSDVersion and operatingsystemSKU. The Caption property was the only easy way to get at the difference betweek SBS 2k3 and Server 2k3 Standard. (One could do bitmapping on SuiteMask, but that's ugly. Though possibly efficient, though I don't think that matters all that much for this.) -- Charlie. http://msmvps.com/xperts64 http://mvp.support.microsoft.com/profile/charlie.russel "Charlie Russel - MVP" <charlie@xxxxxx> wrote in message news:6116302E-00CF-46C6-A17B-4F35EA5575C9@xxxxxx Quote: >I need a way to determine what Windows version and edition a script is >running on. I can get the build number, that's trivial: > > $Build=(get-item 'HKLM:/Software/Microsoft/Windows > NT/CurrentVersion').getvalue('CurrentBuildNumber') > > But it doesn't much help when Windows Vista SP1 is 6001 and so is Windows > Server 2008. And also doesn't tell me which edition. The ProductID: > > $ProductID=(get-item 'HKLM:/Software/Microsoft/Windows > NT/CurrentVersion').getvalue('ProductID') > > could probably do it, but I'm not at all sure what I'm looking at there, > and how to parse it for what's important. First, does anyone know a > reference that gives the relevant numbers for the various editions of > Windows. And second, could someone suggest a regex to parse it into > consituent parts? Or, alternately, does someone have a better location to > get the version and edition of Windows? > > Thanks, > > -- > Charlie. > http://msmvps.com/xperts64 > http://mvp.support.microsoft.com/profile/charlie.russel > > |
My System Specs![]() |
| | #18 (permalink) |
| | Re: Reliable way to get Windows Version? Charlie Russel - MVP wrote: Quote: > Thanks, Jon, Shay, Hal and Andy. Very much appreciated. I've got a > couple of ways to do what I need to do, based on what you gave me. For > the moment, I'm going with a combination of Win32_OperatingSystem > properties, including BuildNumber, Caption, CSDVersion and > operatingsystemSKU. -- Hal Rottenberg Blog: http://halr9000.com Webmaster, Psi (http://psi-im.org) Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
| | #19 (permalink) |
| | Re: Reliable way to get Windows Version? Fairly crude at this point, and I'm not finished doing what I need to do with it, but here's the relevant portion for the moment: $SystemHash = @{} # Initialize the variable as a hashtable $SystemHash["build"] = (Get-WmiObject Win32_OperatingSystem).BuildNumber $SystemHash["SPNumber"] = (Get-WmiObject Win32_OperatingSystem).CSDVersion $SystemHash["Caption"] = (Get-WmiObject Win32_OperatingSystem).Caption $SystemHash["SKU"] = (Get-WmiObject Win32_OperatingSystem).OperatingSystemSKU $SystemHash["Hostname"] = $hostname.ToLower() $SystemHash["Arch"] = $ENV:Processor_Architecture switch -regex ($SystemHash["Build"]) { 2600 { $ver="XP" } 3790 { if ($SystemHash["Caption"] -match "XP") { $ver = "XPx64" } else { $ver = "Server 2003" } } 6000 { $ver="Vista" } 6001 { if ($SystemHash["Caption"] -match "Vista" ) { $ver="Vista" } else { $ver="Server 2008" } } } -- Charlie. http://msmvps.com/xperts64 http://mvp.support.microsoft.com/profile/charlie.russel "Hal Rottenberg" <hal@xxxxxx> wrote in message news:uyMQEOoiIHA.4320@xxxxxx Quote: > Charlie Russel - MVP wrote: Quote: >> Thanks, Jon, Shay, Hal and Andy. Very much appreciated. I've got a couple >> of ways to do what I need to do, based on what you gave me. For the >> moment, I'm going with a combination of Win32_OperatingSystem properties, >> including BuildNumber, Caption, CSDVersion and operatingsystemSKU. > YW. If you can, please report back with your code as a lesson for others. > > > -- > > Hal Rottenberg > Blog: http://halr9000.com > Webmaster, Psi (http://psi-im.org) > Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
| | #20 (permalink) |
| | Re: Reliable way to get Windows Version? Hi Crude indeed too many WMI calls on the same class. You can get all propertiesin one WMI call. To change coulmn names you can use calculated properites. Bear in mind that OperatingSystemSKU is not available on Windows Server 2003, Windows XP, Windows 2000, and Windows NT 4.0. One more thing, $arch is not usefull in case of remote wmi calls: $build = @{n="Build";e={$_.BuildNumber}} $SPNumber = @{n="SPNumber";e={$_.CSDVersion}} $sku = @{n="SKU";e={$_.OperatingSystemSKU}} $hostname = @{n="HostName";e={$_.CSName}} $arch = $ENV:Processor_Architecture $os = Get-WmiObject Win32_OperatingSystem | select $build,$SPNumber,Caption,$sku,$hostname ## If you want the switch statement to stop at the ## first match than add the break statement switch ($os.build) { 2600 {"XP"; break} 3790 { if ($os.caption -match "XP") { "XPx64" } else { "Server 2003" }; break } 6000 {"Vista"; break} 6001 { if ($os.caption -match "Vista" ) { "Vista" } else { "Server 2008" }; break } } ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > Fairly crude at this point, and I'm not finished doing what I need to > do with it, but here's the relevant portion for the moment: > > $SystemHash = @{} # Initialize the variable as a hashtable > $SystemHash["build"] = (Get-WmiObject > Win32_OperatingSystem).BuildNumber > $SystemHash["SPNumber"] = (Get-WmiObject > Win32_OperatingSystem).CSDVersion > $SystemHash["Caption"] = (Get-WmiObject Win32_OperatingSystem).Caption > $SystemHash["SKU"] = (Get-WmiObject > Win32_OperatingSystem).OperatingSystemSKU > $SystemHash["Hostname"] = $hostname.ToLower() > $SystemHash["Arch"] = $ENV:Processor_Architecture > switch -regex ($SystemHash["Build"]) { > 2600 { $ver="XP" } > 3790 { if ($SystemHash["Caption"] -match "XP") { > $ver = "XPx64" > } else { > $ver = "Server 2003" > } > } > 6000 { $ver="Vista" } > 6001 { if ($SystemHash["Caption"] -match "Vista" ) { > $ver="Vista" > } else { > $ver="Server 2008" > } > } > } > "Hal Rottenberg" <hal@xxxxxx> wrote in message > news:uyMQEOoiIHA.4320@xxxxxx > Quote: >> Charlie Russel - MVP wrote: >> Quote: >>> Thanks, Jon, Shay, Hal and Andy. Very much appreciated. I've got a >>> couple of ways to do what I need to do, based on what you gave me. >>> For the moment, I'm going with a combination of >>> Win32_OperatingSystem properties, including BuildNumber, Caption, >>> CSDVersion and operatingsystemSKU. >>> >> others. >> >> -- >> >> Hal Rottenberg >> Blog: http://halr9000.com >> Webmaster, Psi (http://psi-im.org) >> Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Reliable OS? | Vista General | |||
| Just how reliable is Windows Easy Transfer? | Vista General | |||
| most reliable newsreader | Vista mail | |||