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 Variables17: $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 = $strTargetComputer27: $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 Direct33: $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 connection40: $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.CollectionID48: $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
- ‹ previous
- 54 of 55
- next ›
Recent Articles
About the author
![]() |
David O'Brien IT-Consultant Blogs about VDI, AppDNA, Microsoft ConfigMgr and deployment topics in general are my "thing" |





Add Comment