locked
If then statement trouble RRS feed

  • Question

  • During my SCCM OS Deployment I tattoo the registry with the task sequence version which varies depending on type, ie desktop, laptop laptop_french or kiosk. I have written a simple script that provides the user with some basic information and I am trying to write an "if/then" statement that will detect the correct registry entry.

    1. HKLM:\SOFTWARE\TrueBlue\Desktop\Task Sequence Name 
    2. HKLM:\SOFTWARE\TrueBlue\Laptop\Task Sequence Name
    3. HKLM:\SOFTWARE\TrueBlue\Laptop_FR\Task Sequence Name
    4. HKLM:\SOFTWARE\TrueBlue\Kiosk\Task Sequence Name
    Write-Host -NoNewLine "Image Version:      " -ForegroundColor Green
    
      Get-ItemPropertyValue -Path HKLM:\SOFTWARE\TrueBlue\Desktop* -Name "Task Sequence Name" -ErrorAction Ignore
    I have trie several formats but am unable to get it to work.


    DHeinz

    Tuesday, July 24, 2018 2:20 PM

All replies

  • Looks/Sounds weird. Why don't you create a key like HKLM:\SOFTWARE\TrueBlue\TSName and in this key a value with the actual Task Sequence Name?

    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, July 24, 2018 2:29 PM
  • if($tsname = (Get-ItemPropertyValue -Path HKLM:\SOFTWARE\TrueBlue\Desktop -Name 'Task Sequence Name' -EA 0).'Task Sequence Name'){
        $tsname
    }else{
        'not found'
    }

    Your design of the registry keys is a problem for coding.  You should place the TS name in the root an use a simple name.

    KEY: HKLM:\SOFTWARE\TrueBlue  Property: TSName
    KEY:  HKLM:\SOFTWARE\TrueBlue  Property: DeviceType

    This would simplify the queries and set you up to grab the direct device key directly.


    \_(ツ)_/


    • Edited by jrv Tuesday, July 24, 2018 2:34 PM
    Tuesday, July 24, 2018 2:33 PM