The example Powershell script creates a computer / device object in SCCM 2012.
[[powershell]]
$SiteCode = "MEL"
$SiteServer = "."
#Add Computer to System
$wmi = [WmiClass]"\\$($SiteServer)\ROOT\SMS\Site_$($SiteCode):SMS_Site"
$InObject = $wmi.psbase.GetMethodParameters(“ImportMachineEntry”)
$InObject.MACAddress = "00:50:56:C0:00:08"
$InObject.NetbiosName = "wmel001"
$InObject.OverwriteExistingRecord = "true"
$InObject.SMBIOSGUID = "9310E1C0-D7DA-11DD-9AA6-60A44CAF553C"
$wmi.PSBase.InvokeMethod("ImportMachineEntry", $InObject, $Null)
#Update All Systems Collection
$CollectionName = "All Systems"
$CollectionQuery = Get-WmiObject -Namespace "Root\SMS\Site_$($SiteCode)" -Class SMS_Collection -Filter "Name='$CollectionName'"
$CollectionQuery.RequestRefresh()
[[/powershell]]
The example uses WMI to create a Device from the SCCM Server. My use for this script is to use Orchestrator in creating accounts as part of a provisioning process. To assist, the second component of the script requests that the All Systems collection is refreshed.
In a previous post I provided a simple vbscript that could be used to harvest UUID / SMBIOS and MAC Address details from machines in CSV format (which may be of comparative value).
- Log in to post comments