Results 1 to 7 of 7
  1. #1
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,058
    Thanks
    196
    Thanked 766 Times in 700 Posts

    Version-checking script still not working

    Hey Y'all,

    I ran this PowerShell Script again today after applying more system updates ( including I guess the supposed Win 8.1 Update 2 ) and still get the same results as in this post. I couldn't reply to the original post as it was more than 194 days old.

    Any IDEAS?

    Code:
    <# +-------------------------------------------+
       | Program Name : CurrentOS.ps1              |
       | Programmed by: ComputerMentor             |
       |           AKA: RetiredGeek                |
       | Created      : 02/01/2014                 |
       | Last Update  : 07/18/2014                 |
       | Version No.  : 1.1                        |
       | Requirements.:                            |
       +-------------------------------------------+
    #>
    Get-CimClass -PropertyName version -QualifierName dynamic | Out-Null
    Clear-Host
    
    Write-Host 'Output for: Get-CimInstance Win32_OperatingSystem'
    
    $CurOS = Get-CimInstance Win32_OperatingSystem
    $CurOS | Select CSName, Caption, Systemdirectory, BuildNumber,RegisteredUser,SerialNumber, Version
    
    <#  -------  Sample Output Win 8.1  -------------
    CSName          : DELLXPS8700
    Caption         : Microsoft Windows 8.1 Pro
    Systemdirectory : C:\WINDOWS\system32
    BuildNumber     : 9600
    RegisteredUser  : Windows User
    SerialNumber    : 00178-11197-21867-AB377
    Version         : 6.3.9600
    #>
    
    Write-Host 'Output for: $CurOS | Select Caption,Version,RegisteredUser'
    
    $CurOS | Select Caption,Version,RegisteredUser | Format-List
    
    <#  -------  Sample Output Win 8.1  -------------
    Caption        : Microsoft Windows 8.1 Pro
    Version        : 6.3.9600
    RegisteredUser : Bruce
    #>
    
    Write-Host 'Output for: [System.Environment]::OSVersion.Version'
    
    [System.Environment]::OSVersion.Version | Format-List
    
    <#  -------  Sample Output Win 8.1  -------------
    Major         : 6
    Minor         : 2
    Build         : 9200
    Revision      : 0
    MajorRevision : 0
    MinorRevision : 0
    #>
    
    $FullVersion = $CurOS.Version
    $VersionItems = $FullVersion.split('.')
    
    Write-Host 'Output for $CurOS.Version split into parts:'
    Write-Host "Major OS Version:" $VersionItems[0] 
    Write-Host "Minor OS Version:" $VersionItems[1] 
    Write-Host "         Build #:" $VersionItems[2] "`n"
    
    <#  -------  Sample Output Win 8.1  -------------
    Output for $CurOS.Version split into parts:
    Major OS Version: 6
    Minor OS Version: 3
             Build #: 9600
    #>
    
    # Test to see if user is running Win 8.1 or later.
    
    If($VersionItems[0] -lt 6) {
      Write-Host "Test1: You must have Windows 8.1 or later to run this program."
    }
    Else {
      If($VersionItems[0] -eq 6 -and $VersionItems[1] -lt 3) {
        Write-Host "Test2: You must have Windows 8.1 or greater to run this program."
      }
      Else {
         Write-Host "You  have the proper OS support to run this program."
      }
    }
    Last edited by RetiredGeek; 2014-08-13 at 15:22.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    20,416
    Thanks
    1
    Thanked 597 Times in 534 Posts
    Works on my system which 8.1 Enterprise.

    Joe

  4. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,058
    Thanks
    196
    Thanked 766 Times in 700 Posts
    Joe,

    Could you post your output?
    What version was your initial install?
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  5. #4
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    20,416
    Thanks
    1
    Thanked 597 Times in 534 Posts
    I installed 8.0 Enterprise first. Here's the output (note: I obscured the serial number):

    PS C:\Users\Joe> Write-Host 'Output for: Get-CimInstance Win32_OperatingSystem'
    Output for: Get-CimInstance Win32_OperatingSystem
    PS C:\Users\Joe>
    PS C:\Users\Joe> $CurOS = Get-CimInstance Win32_OperatingSystem
    PS C:\Users\Joe> $CurOS | Select CSName, Caption, Systemdirectory, BuildNumber,RegisteredUser,SerialNumber, Version


    CSName : JOE-PC
    Caption : Microsoft Windows 8.1 Enterprise
    Systemdirectory : C:\WINDOWS\system32
    BuildNumber : 9600
    RegisteredUser : Joe
    SerialNumber : xxxxx-xxxxx-xxxxx-xxxxx
    Version : 6.3.9600



    PS C:\Users\Joe>
    PS C:\Users\Joe> <# ------- Sample Output Win 8.1 -------------
    >> CSName : DELLXPS8700
    >> Caption : Microsoft Windows 8.1 Pro
    >> Systemdirectory : C:\WINDOWS\system32
    >> BuildNumber : 9600
    >> RegisteredUser : Windows User
    >> SerialNumber : XXXXX-XXXXX-XXXXX-XXXXX
    >> Version : 6.3.9600
    >> #>
    >>
    PS C:\Users\Joe> Write-Host 'Output for: $CurOS | Select Caption,Version,RegisteredUser'
    Output for: $CurOS | Select Caption,Version,RegisteredUser
    PS C:\Users\Joe>
    PS C:\Users\Joe> $CurOS | Select Caption,Version,RegisteredUser | Format-List


    Caption : Microsoft Windows 8.1 Enterprise
    Version : 6.3.9600
    RegisteredUser : Joe



    PS C:\Users\Joe>
    PS C:\Users\Joe> <# ------- Sample Output Win 8.1 -------------
    >> Caption : Microsoft Windows 8.1 Pro
    >> Version : 6.3.9600
    >> RegisteredUser : Bruce
    >> #>
    >>
    PS C:\Users\Joe> Write-Host 'Output for: [System.Environment]::OSVersion.Version'
    Output for: [System.Environment]::OSVersion.Version
    PS C:\Users\Joe>
    PS C:\Users\Joe> [System.Environment]::OSVersion.Version | Format-List


    Major : 6
    Minor : 3
    Build : 9600
    Revision : 0
    MajorRevision : 0
    MinorRevision : 0



    PS C:\Users\Joe>
    PS C:\Users\Joe> <# ------- Sample Output Win 8.1 -------------
    >> Major : 6
    >> Minor : 2
    >> Build : 9200
    >> Revision : 0
    >> MajorRevision : 0
    >> MinorRevision : 0
    >> #>
    >>
    PS C:\Users\Joe> $FullVersion = $CurOS.Version
    PS C:\Users\Joe> $VersionItems = $FullVersion.split('.')
    PS C:\Users\Joe>
    PS C:\Users\Joe> Write-Host 'Output for $CurOS.Version split into parts:'
    Output for $CurOS.Version split into parts:
    PS C:\Users\Joe> Write-Host "Major OS Version:" $VersionItems[0]
    Major OS Version: 6
    PS C:\Users\Joe> Write-Host "Minor OS Version:" $VersionItems[1]
    Minor OS Version: 3
    PS C:\Users\Joe> Write-Host " Build #:" $VersionItems[2] "`n"
    Build #: 9600

    PS C:\Users\Joe>
    PS C:\Users\Joe> <# ------- Sample Output Win 8.1 -------------
    >> Output for $CurOS.Version split into parts:
    >> Major OS Version: 6
    >> Minor OS Version: 3
    >> Build #: 9600
    >> #>
    >>
    PS C:\Users\Joe> # Test to see if user is running Win 8.1 or later.
    PS C:\Users\Joe>
    PS C:\Users\Joe> If($VersionItems[0] -lt 6) {
    >> Write-Host "Test1: You must have Windows 8.1 or later to run this program."
    >> }
    >> Else {
    >> If($VersionItems[0] -eq 6 -and $VersionItems[1] -lt 3) {
    >> Write-Host "Test2: You must have Windows 8.1 or greater to run this program."
    >> }
    >> Else {
    >> Write-Host "You have the proper OS support to run this program."
    >> }
    >> }

    Joe

  6. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,058
    Thanks
    196
    Thanked 766 Times in 700 Posts
    Joe,

    This is weird! Your post gave me the idea to try the Command Console vs the ISE.

    Using 64-Bit PS ISE I get:
    64BitISE.JPG

    However, running 64-Bit PS CMD I get:
    64BitCMD.JPG

    Note: Both are running in Administrator mode and both show the same values for $PSVersionTable:
    Code:
    PS G:\bekdocs\scripts> $PSVersionTable
    
    Name                           Value                                           
    ----                           -----                                           
    PSVersion                      4.0                                             
    WSManStackVersion              3.0                                             
    SerializationVersion           1.1.0.1                                         
    CLRVersion                     4.0.30319.34014                                 
    BuildVersion                   6.3.9600.17090                                  
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}                            
    PSRemotingProtocolVersion      2.2
    As I said before I'm stumped!
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  7. #6
    New Lounger
    Join Date
    Dec 2009
    Location
    Gillingham, Dorset, UK
    Posts
    5
    Thanks
    0
    Thanked 2 Times in 2 Posts
    RetiredGeek, it would appear that this is a known "feature" of Windows 8.1. Take a look at this article:

    http://blogs.technet.com/b/heyscript...m-version.aspx

  8. The Following User Says Thank You to Cliff.H For This Useful Post:

    RetiredGeek (2014-08-14)

  9. #7
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,058
    Thanks
    196
    Thanked 766 Times in 700 Posts
    Cliff,

    Thank you!
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •