I want to add it to my TSVariable table, but struggling. How can i add a member to the PSObject without removing what is there ? Or is there a better way ?
This is more of a question for an SCCM thread on Operating System Deployment. If memory serves, the MDT toolkit contains all of the scripts that are doing the same thing, running a WMI query and creating TS Variables for IsDesktop, IsLaptop and IsVM. The last time I worked with MDT, all of the scripts were VBScript.
You could find the script that is setting this information in the task sequence and add your code. Problem is when you deploy a new MDT toolkit version, you have to re-add the code to the script. Replacing is risky if they've made improvements in the script, you would replace with old code and could break things with cryptic smsts.log errors
You could create a script like above and place it in the MDT Toolkit package and call it after your OS is installed to set it just like you are talking about. I would recommend a naming convention using your company initials so when you are doing a MDT Toolkit update, you can find your scripts quickly (e.g. ztiTCAddIsTablet.vbs for Tech Corporation).
I would modify it to not do the TS variable stuff and test it on a tablet to ensure you are getting TRUE on there and FALSE on Desktops, VMs and Laptops.
So, if $Models contains more than one object (making it a “collection,” not a “list”), you can’t do that. You have to add members to individual objects, one at a time. If $Models has multiple objects, that means a ForEach loop to enumerate them.
But let’s break down and make sure I’m understanding your code.
It’d probably be easier to just add the property inside that ForEach loop, no? Run your WMI query, figure out if it’s a tablet or not, and then build your object with whatever value you want?
Hi Don,
Thank you. Yes, i want to add a new “object” to the existing objects…if that makes sense ! But the new object is evaluated in a different way to the other 3, in this case.
You want to add a new object to the existing collection of objects. So you can use the code I just posted to do that. You can see where I assigned the value $whatever; you’d just put your $True or $False in there before creating the new, fourth object.