Win7 Detection Issue

Welcome Forums General PowerShell Q&A Win7 Detection Issue

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
2 years, 11 months ago.

  • Author
    Posts
  • #42088

    Participant
    Topics: 2
    Replies: 4
    Points: 0
    Rank: Member

    I am in the process of making a powershell task sequence to fire off to complete some tasks that otherwise would be run manually after a newly imaged computer is complete. One of them is to detect if the machine is Windows 7, if it is perform a certain task.

    I am running this on a VM as well as a spare production laptop and it always opens up IEXPLORE (in my example below) and not notepad. When I type $OS it comes back with "Microsoft Windows 7 Enterprise".

    If I run this on my Windows 10 computer and adjust the "If ($OS -contains 'Microsoft Windows 10 Pro')", it works as it should.

    Am I missing something here?

  • #42096

    Participant
    Topics: 3
    Replies: 263
    Points: 73
    Helping Hand
    Rank: Member

    Change your IF statement to this. '-Contains' operator is used to verify if elements are in an array.

    $caption = (Get-WmiObject win32_operatingsystem).caption.Trim()
    If ($caption -eq 'Microsoft Windows 7 Enterprise'){Start-Process...}
    
    • #42103

      Participant
      Topics: 2
      Replies: 4
      Points: 0
      Rank: Member

      You are fantastic. Thank you for the info and assistance!

The topic ‘Win7 Detection Issue’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort