none
Task Sequence - unknown computer variable RRS feed

  • Question

  • hello everyone,

    I would like to run a few things for a machine that is discovered as UNKNOWN. I bring in a new computer and it does not exist in SCCM, MAC is not known nor is UUID. Question is - how do I create a task sequence condition to use a variable or a query to make sure it runs only with an unknown computer?

    Thanks

    Jakub

    Friday, June 10, 2016 8:26 AM

Answers

  • Unknown meaning it does not exist in SCCM, its GUID or MAC address are not associated to any computer object there. I actually managed to figure this one out myself. Here is the script

    #create object to access variables
    $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment

    #create a TS variable and call it IsKnown and assing a value of 1.
    $TSEnv.value('IsKnown') = 1

    #get WMI Name from Computer system class
    $WMIName = Get-WMIObject -class win32_ComputerSystem | Select -ExpandProperty Name
    #read TS variable _SMSTSMachineName and assign to a variable
    $OSDNAme = $TSEnv.value('_SMSTSMachineName')

    #Compare whether the names are the same
    if($WMIName -eq $OSDName){$TSEnv.value('IsKnown') = 0}
    if($OSDName = $null){$TSEnv.value('IsKnown') = 0}
    if($OSDName = ""){$TSEnv.value('IsKnown') = 0}

    The condition checks if the two variables - Task Sequence variable _SMSTSMachineName and WMI variable Name from Computer System class are in fact the same. If a machine is known, _SMSTSMAchineName is going to be the previous machine name that this PC had when it was first built. The WMIName will always be something like MININT-***** in Windows PE. When these two match - machine is unknown and is not in SCCM. When these two are different or blank, the machine is known. Seems to be doing the job!


    • Marked as answer by Jakub Fuczek Saturday, June 11, 2016 11:41 AM
    • Edited by Jakub Fuczek Saturday, June 11, 2016 7:49 PM
    Saturday, June 11, 2016 11:40 AM

All replies

  • What do you mean exactly by "discovered as UNKNOWN"?  Do you actually see UNKNOWN somewhere?  Is it in one of the MDT logs?
    Friday, June 10, 2016 7:39 PM
  • Unknown meaning it does not exist in SCCM, its GUID or MAC address are not associated to any computer object there. I actually managed to figure this one out myself. Here is the script

    #create object to access variables
    $TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment

    #create a TS variable and call it IsKnown and assing a value of 1.
    $TSEnv.value('IsKnown') = 1

    #get WMI Name from Computer system class
    $WMIName = Get-WMIObject -class win32_ComputerSystem | Select -ExpandProperty Name
    #read TS variable _SMSTSMachineName and assign to a variable
    $OSDNAme = $TSEnv.value('_SMSTSMachineName')

    #Compare whether the names are the same
    if($WMIName -eq $OSDName){$TSEnv.value('IsKnown') = 0}
    if($OSDName = $null){$TSEnv.value('IsKnown') = 0}
    if($OSDName = ""){$TSEnv.value('IsKnown') = 0}

    The condition checks if the two variables - Task Sequence variable _SMSTSMachineName and WMI variable Name from Computer System class are in fact the same. If a machine is known, _SMSTSMAchineName is going to be the previous machine name that this PC had when it was first built. The WMIName will always be something like MININT-***** in Windows PE. When these two match - machine is unknown and is not in SCCM. When these two are different or blank, the machine is known. Seems to be doing the job!


    • Marked as answer by Jakub Fuczek Saturday, June 11, 2016 11:41 AM
    • Edited by Jakub Fuczek Saturday, June 11, 2016 7:49 PM
    Saturday, June 11, 2016 11:40 AM