Import eines Computers in Configuration Manager 2007 / 2012

by David O'Brien on 02/15/2013 | 0 Comments | 1,318 Views

Nur ein ganz kurzer Artikel:

Mit diesem Skript könnt ihr einen Computer in eure Microsoft System Center Configuration Manager-Umgebung importieren.

 1: #####
 2: # Function: Import-ConfigMgr
 3: # This function imports a given client into a defined collection.
 4: # Ersteller: David O'Brien
 5: # Erstellt am: 14.07.2011
 6: #####
 7: Function Import-ConfigMgr
 8: {
 9: ### Define variables to import the client to ConfigMgr
 10: $strTargetComputer = $computername
 11: $strTargetMac = $computerMAC
 12:  
 13: ### Which collection should the client be imported to?
 14: $strTargetCollection = 'Install ' + $computerOS # in my environment a Client automatically gets a machine variable $computerOS
 15:  
 16: ### Load Variables
 17: $strSite = "Site_LAB"
 18:  
 19: # Create computer in ConfigMgr
 20: $strColon = ":"
 21: $Class = "SMS_Site"
 22: $Method = "ImportMachineEntry"
 23: $MC = [WmiClass]"\\.\ROOT\SMS\$strSite$strColon$Class"
 24: $InParams = $mc.psbase.GetMethodParameters($Method)
 25: $InParams.MACAddress = $strTargetMac
 26: $InParams.NetbiosName = $strTargetComputer
 27: $InParams.OverwriteExistingRecord = $true
 28: $inparams.PSBase.properties | select name,Value | Format-Table
 29: $objCMComputer = $mc.PSBase.InvokeMethod($Method, $inParams, $Null)
 30:  
 31:  
 32: # Create Collection Rule Direct
 33: $Class = "SMS_CollectionRuleDirect"
 34: $objColRuledirect = [WmiClass]"\\$Computer\ROOT\SMS\$strSite$strColon$Class"
 35: $objColRuleDirect.psbase.properties["ResourceClassName"].value = "SMS_R_System"
 36: $objColRuleDirect.psbase.properties["ResourceID"].value = $objCMComputer.resourceID
 37:  
 38:  
 39: # Target Collection connection
 40: $Collection = gwmi -computer $computer -namespace "root\sms\$strSite" -class "SMS_Collection"
 41: $PoshCollec = $collection | where{$_.Name -eq "$strTargetCollection"}
 42:  
 43:  
 44: # Add Computer to Target Collection
 45: $Class = "SMS_Collection"
 46: $Method = "AddMembershipRule"
 47: $CollectionID = $PoshCollec.CollectionID
 48: $filter="CollectionID = '$CollectionID'"
 49: $MC = Get-WmiObject $class -computer $Computer -Namespace "ROOT\SMS\$strSite" -filter $filter
 50: $InParams = $mc.psbase.GetMethodParameters($Method)
 51: $InParams.collectionRule = $objColRuledirect
 52:  
 53: $inparams.PSBase.properties | select name,Value | Format-Table
 54: $R = $mc.PSBase.InvokeMethod($Method, $inParams, $Null)
 55: }

Das Skript muss auf einem ConfigMgr-Management Point ausgeführt werden.

Fragen? Her damit! Wie immer hier oder auf Twitter: @david_obrien

Add Comment

Der Inhalt dieses Feldes wird nicht öffentlich angezeigt.
Sicherheitscode
Diese Frage hat den Zweck zu testen, ob Sie ein menschlicher Benutzer sind und um automatisierten Spam vorzubeugen.
Bild-CAPTCHA
reload image
Geben Sie die Zeichen ein, die im Bild zu sehen sind.

Microsoft Competence Blog

Application Infrastructure mit Microsoft Technologien ist ein wichtiges Fokusthema der sepago. Wir haben langjährige Projekterfahrung, sind neugierig auf neue Technologien und möchten diese bis in letzte Detail verstehen. Die Competence Blogs berichten davon.

RSS-Feed Alle Artikel des Competence Blogs abonnieren.

 

About the author

Bild von David O'Brien
David O'Brien
IT-Consultant
Blogs about VDI, AppDNA, Microsoft ConfigMgr and deployment topics in general are my "thing"

All articles