Forum Discussion
ToptechnicalSolutions
Feb 24, 2022Copper Contributor
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...
- Feb 28, 2022
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.
ToptechnicalSolutions
Mar 01, 2022Copper Contributor
So I would literally add a run command line
cmd /c powershell.exe -Command "&{$Me = $Env:COMPUTERNAME; Invoke-command -Computername OURSERVER -ArgumentList $Me -scriptblock {param($Me)Import-Module ConfigurationManager; cd IP1:; $Computer = Get-CMDevice -Name $Me; if ($Computer){Add-CMDeviceCollectionDirectMembershipRule -CollectionName 'HP Elitebook 830 G8' -Resource $Computer}}}"
And add the options tab
SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%HP EliteBook 830 G8%"
Then when I build any machine it will go into the “all desktop and server clients” but if it’s a HP elite book it will go into the HP elitebook 830 G8 collection?
cmd /c powershell.exe -Command "&{$Me = $Env:COMPUTERNAME; Invoke-command -Computername OURSERVER -ArgumentList $Me -scriptblock {param($Me)Import-Module ConfigurationManager; cd IP1:; $Computer = Get-CMDevice -Name $Me; if ($Computer){Add-CMDeviceCollectionDirectMembershipRule -CollectionName 'HP Elitebook 830 G8' -Resource $Computer}}}"
And add the options tab
SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%HP EliteBook 830 G8%"
Then when I build any machine it will go into the “all desktop and server clients” but if it’s a HP elite book it will go into the HP elitebook 830 G8 collection?
Mar 02, 2022
You didn't write the server name in the Properties section.
- Mar 02, 2022You're welcome 🙂
- ToptechnicalSolutionsMar 02, 2022Copper Contributoryou are amazing thanks for your help on this.
- Mar 02, 2022All machines, whether HP Elitebook or not, are added to the All Desktop collection. Only computers with HP EliteBooks are added to the HP Elitebook collection.
- ToptechnicalSolutionsMar 02, 2022Copper ContributorBut for new machines being built as new machines that are not HP machines will they go into the main "All desktop" collection and if it is a HP elitebook and we build a new one it will go into the HP elitebook collection?
- Mar 02, 2022Any machine that is already a SCCM agent will be in the collection of all desktop and server clients. However, if the model is HP EliteBook 830 G8, it will be in both all desktop and server clients and HP ELiteBook 380 G8 collections.
- ToptechnicalSolutionsMar 02, 2022Copper ContributorYeah I know I just put our server but I will change that.
But I just wanted to confirm that when I add this run command line and the option tab then when I build any machine it will go into the “all desktop and server clients” but if it’s a HP elite book it will go into the HP elitebook 830 G8 collection