This topic contains 1 reply, has 2 voices, and was last updated by
April 9, 2015 at 7:32 am #24104ParticipantPoints: 0Rank: Member
I want to put a script at the end of the build to move a computer to a collection. Long story short, the SCCM Agent takes a bit too long after build so the hardware scan won't run due to the SMS_Client not being populated. So this script is a kind of work around. So the details i've pulled so far are:
$SiteCode = "AAC"
$CMProvider = "Server"
$GetValues = New-Object -ComObject microsoft.sms.TSEnvironment
$OSDDepartment = $GetValues.Value('OSDDepartment')
$OSDComputerName = $GetValues.Value('OSDComputerName')
$TargetCollection = Get-WmiObject -Namespace "Root\SMS\Site_AAC" -Class SMS_Collection | Where-Object name -eq $OSDDepartment
$SourceCollection = Get-WmiObject -Namespace "Root\SMS\Site_AAC" -Class SMS_Collection | Where-Object name -eq "All Systems"
Get-WmiObject -Namespace "Root\SMS\Site_AAC" -Class SMS_G_System_COMPUTER_SYSTEM | where-object Name -eq "$OSDComputerName"
The method of Copy() i'm not sure how it works. But i can get the PC name during OSD and our "Department" branding variable created from an HTA. By referring to the SCCM server i can hopefully get around the SMS_Client local not being populated. The other way would be doing a test-connection a loop check every 30 seconds to see if the WMI SMS_Client has been created.
I hope this makes sense !
April 9, 2015 at 10:02 am #24108ParticipantPoints: 527Rank: Major Contributor
What you are trying to do makes sense, but now how you are trying to accomplish it. SCCM computers are objects and collections are a subscription. For instance, in Active Directory you have computer object and OU's are containers and can only be in one OU. In SCCM computers can be part of multiple collections, they are not moved from a collection into another collection. You don't copy computers, it's a single object, so it's either added (subscribed) or removed from a collection. Computers are added to collections either by a query or direct rule that qualifies them to be in a collection. The logic is more like this:
– Search SCCM for the computer
– Search SCCM for the collection
-Create a direct rule placing the found computer into the found collection
There are a lot of examples on the internet to do what you are trying to do. The first link uses Powershell and WMI, the second uses cmdLets in SCCM 2012 and the third is VBScript, but shows the logic of the steps used to add a computer into an SCCM collection.
The topic ‘SCCM move Computer between device collections’ is closed to new replies.