Forum Discussion
Script for SCCM Help please
Hi,
I have a setup with SCCM at the moment which works fine for building machines but I need to run a command after the OS is loaded for task sequence which is 'wmic csproduct get name" and then the output from this I need to be added to the device if the model is HP as follows "SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%HP Elitebook%”" and then if this is true add this to the device variable info in SCCM. Is this possible?
The reason is i have setup bitlocker in SCCM and I have a set of HP machines I need this applied to only not other devices when its being built. Can anyone please help.
Thanks
This link will help you to add a device to a collection during your OS deployment via Task Sequence.
Add a Device to a Collection during a Task Sequence (smsagent.blog)
After you add that step your task sequence, You can add a WMI query for define HP EliteBooks on options tab.
I think that will solve your problem.
34 Replies
I understand you want to Enable Bitlocker for only HP EliteBook models. Is it right?
If your answer is yes please try that method which is below.
Task Sequence -> Add -> Disk -> Enable Bitlocker
Properties Tab -> Configure your settings
Options Tab -> Add Condition -> Query WMI -> SELECT * FROM Win32_ComputerSystem WHERE Model LIKE “%HP Elitebook%” -> OK.
Best Regards
- ToptechnicalSolutionsCopper Contributor
hasanemresatilmis Thank you for your info. The way we have this at the moment is we have device collection group and the device collection setup as we have multiple models. So this is what we have at the moment and we have the device collection group called below and the device collections itself which is the HP elitebook 830 G8 which has a query rule against it.
What I need is when we deploy our standard build and after the OS is deployed we have a task sequence that runs the command wmic csproduct get name and then if it gets the HP elitebook 830 G8 as a name I need this to populate the device variable.
Is this possible?
Thanks
You can use this script for devices which devices in HP EliteBook collection.
#SCCM Installation Path CD 'D:\Program Files\Microsoft Configuration Manager\AdminConsole\bin' #Import Module Import-Module .\ConfigurationManager.psd1 #Enter Site (EHS is my site code) Set-Location EHS: #Getting Devices by Collection Name $Devices = Get-CMCollectionMember -CollectionName "HP Elitebooks" #Add EnableBitlocker Variable and value foreach ($Device in $Devices) { New-CMDeviceVariable -DeviceName $Device.Name -VariableName "EnableBitLocker" -VariableValue "True" -IsMask 0 }