A step-by-step guide to extend Hardware Inventory in SCCM for collecting SIM ICCID

UPDATE 05.12.2018: Had a case with customer to implement this and had some time to re-visit this post again. Thanks to Todd Wilkolak and Clayton from the comment field I have made some adjustments to the PowerShell script.

I had request from my customer to extend the SCCM HW inventory to collect the SIM ICCID (Integrated Circuit Card ID). This is the identifier of the actual SIM card itself – i.e. an identifier for the SIM chip. Also the request was to get mobile broadband provider name.

This article is divided into three major steps:

Step 1: Server Side Configuration

Step 2: Client Side Configuration

Step 3: Processing the Hardware Inventory with NOIDMIF data

Step 1: Server Side Configuration

First we will create the MOF file according to a requirement specified, SIM ICCID and Provider Name.

We will pull the following information using NOIDMIF files from a SCCM client machine.

SIM_ICCID

Provider_Name

The MOF for creating a Class and its Attribute is as follows:

[ SMS_Report (TRUE),
SMS_Group_Name ("MobileBroadband_Information"),
SMS_Class_ID ("SIM_ICCID")]
class MobileBroadband_InformationInventory : SMS_Class_Template
{
[SMS_Report (TRUE),key ] string SIM_ICCID;
[SMS_Report (TRUE) ] string Provider_Name;
};

To create the MOF file, simply copy the lines above in red into Notepad and save the file with the extension .MOF

“MobileBroadband_Information” is the Group name which you will see in the Resource explorer under Hardware.

“SIM_ICCID” is the name of the Class.

“Highlighted” portion are Attributes whose values will be fetched up by processing the Hardware Inventory.

NOTE: You can create more attributes as per your specific requirements.

Once the file is saved with a .MOF extension we need to import it. To do this, go to the console and open Client Settings, choose Default Client Settings, since you can only extend the HW inventory on this Client Settings. Browse to Hardware Inventory and click on “Set Classes”1

Then click on “Import”2

Browse to the location where you have saved the .MOF file and click Open3

Select the option “Import both Hardware Inventory Classes and Hardware Inventory Class Settings”

4

Once the Hardware Inventory class is imported, verify that the class is added by searching for it using its class name. By default it’s already selected but if not then select the Class. You can expand the Class to look into its Attributes as well.5

After importing the MOF, be sure you enable the collection of NOIDMIF files as shown below.

6

Now you can verify that new tables are created regarding the above class “SIM_ICCID” in the database.

78

At this point the configuration on the server side is completed so we will now move to the client side.

Step 2: Client Side Configuration

On the client side we need to create a .MIF file and copy it to the required location. The PowerShell script will create the .MIF file with its Class “SIM_ICCID” and its attributes specified below:

Start Component
Name = "System_InformationInventory"
   Start Group
     Name = "Mobile Broadband Information"
     ID = 1
     Class = "MobileBroadbandInformation"
     Start Attribute
       Name = "SIM_ICCId "
       ID = 1
       Type = String(40)
       Value = "12358022150401090967"
     End Attribute
     Start Attribute
       Name = "Provider_Name"
       ID = 2
       Type = String(80)
       Value = "elisa"
     End Attribute
   End Group
End Component

The highlighted two attributes above are required in our example. You can create more attributes to suit your specific requirements, but if you do, make sure the same Class and Attributes are created on the server side as well.

The .MIF file is created to the location: %Windir%\CCM\Inventory\Noidmifs

Let’s get the script rolling…

We will execute to commands:

Cmd.exe /c "netsh mbn show interface"

This will give us the following info of the mobile broadband interface:

There is 1 interface on the system:

   Name               : Matkapuhelinverkko
   Description       : Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card
   GUID               : {CA732FF4-3AB8-424B-9899-81345BA2C713}
   Physical Address   : 1a:2b:3c:4d:5e:12
   State             : Locked
   Device type       : Mobile Broadband device is embedded in the system
   Cellular class     : GSM
   Device Id         : 123456789123456
   Manufacturer       : Sierra Wireless, Incorporated
   Model             : Dell Wireless 5570 HSPA+ (42Mbp
   Firmware Version   : SWI9X15C_01.12
   Provider Name     : Elisa
   Roaming           : Not roaming
   Signal             : 0%
   RSSI / RSCP       : 0 (-113 dBm)

From this info we will pick the provider name.

The second command that we will execute is

Cmd.exe /c "netsh mbn show read i=*"

This will give us the following info of the mobile broadband interface:

 Ready information for interface Matkapuhelinverkko:
-------------------------------------
   State           : Ready to power up and register
   Emergency mode   : Off
   Subscriber Id   : 123456789012345
   SIM ICC Id       : 1234567890123456789
   Number of telephone numbers : 0

From this info we will pick the SIM ICC Id.

I have created a PowerShell to build the MIF file:

<#
#requires -version 3
#Requires -RunAsAdministrator
.DESCRIPTION
This script will get the information from the Mobile broadband interface, also called wireless wide area network (WWAN) service.
The collected information is then written to MIF -file that the SCCM will then collect to HW inventory.
.COPYRIGHT
The MIT License (MIT)
.LICENSEURI
https://opensource.org/licenses/MIT
.PARAMETER <Parameter_Name>
None
.INPUTS
None
.OUTPUTS
Log file stored in path specified by the variable $Logpath. Please see variable section.
MIF -file is created to %windir%\CCM\Inventory\Noidmifs\MobileBroadband.mif
.NOTES
Documentation: https://contosoniku.wordpress.com/2016/12/06/a-step-by-step-guide-to-extend-hardware-inventory-in-sccm-for-collecting-sim-iccid/
Version: 1
Author: Nicklas Halme
Creation Date: 15.03.2016
Purpose/Change: Initial script development
Version: 2
Author: Nicklas Halme
Creation Date: 05.12.2018
Change: – Changed the logic how the information is processed based on Todd Wilkolak and Clayton's feedback
– Modified the Logging -function
– Removed the Parse -function
.EXAMPLE
None
#>
#———————————————————————————————————-
#
# Global Editable Variables
#
#———————————————————————————————————-
#Log File Info
$LogPath = "$env:SystemRoot\Logs"
$LogFileName = "$env:Computername-MobileBroadband_$(get-date -format `"yyyy-MM-dd`").log"
$LogFile = Join-Path -Path $LogPath -ChildPath $LogFileName
#———————————————————————————————————-
#
# Function Definition
#
#———————————————————————————————————-
#
#————————————–
# Write to log file
#————————————–
function Write-LogEntry($msg,$ForegroundColor) {
if ($ForegroundColor -eq $null) { $ForegroundColor = [System.ConsoleColor]::White }
If ((Test-Path $LogPath) -eq $False) { new-item -Path $LogPath -ItemType Directory }
$LogDate = Get-Date -Format "yyyy-MM-dd HH.MM.ss"
Write-Host "$LogDate : $msg" -ForegroundColor $ForegroundColor
"$LogDate : $msg" | Out-File $LogFile -Append
}
#—————————————————————————————————————-
#
# Main Execution
#
#—————————————————————————————————————-
Write-LogEntry "******** Script Started ********" -ForegroundColor cyan
Write-LogEntry "Logging to: $LogFile"
Write-LogEntry "Get the content from the 'netsh mbn show interface' command."
$get_MBInfo = cmd /c "netsh mbn show interface"
Write-LogEntry "Read the content…"
If ($get_mbinfo -like "*There is no Mobile Broadband interface*") {
Write-LogEntry "There is no Mobile Broadband interface. Set the inventory status…" -ForegroundColor Yellow
$DeviceID = "No Mobile Broadband interface"
$ICCID = "No Mobile Broadband interface"
}
If ($get_mbinfo -like "*Mobile Broadband Service (wwansvc) is not running.*") {
Write-LogEntry "wwansvc service is not running. Set the inventory status…" -ForegroundColor Yellow
$DeviceID = "wwansvc is not running"
$ICCID = "wwansvc is not running"
}
# Read the second line (NOTE: line numbering start from 0) of the content
If ($get_mbinfo[1] -like "*There is 1 interface on the system:*") {
Write-LogEntry "There is 1 interface on the system…" -ForegroundColor Green
# Read info from specific line and split the line with ':'-delimeter. Trim spaces from the beginning and end of a string.
Write-LogEntry "Get Provider Name: Read info from specific line (16) and split the line with ':'-delimeter. Trim spaces from the beginning and end of a string."
$ProviderName = $get_mbinfo[16].Split(":")[1].Trim()
Write-LogEntry "Get the content from the 'netsh mbn show read i=*' command."
$get_iccid = cmd /c "netsh mbn show read i=*"
Write-LogEntry "Get SIM ICC ID: Read info from specific line (5) and split the line with ':'-delimeter. Trim spaces from the beginning and end of a string." -ForegroundColor Green
$ICCID = $get_iccid[5].Split(":")[1].Trim()
}
Write-LogEntry "Create the inventory results to MIF -file (MobileBroadband.mif) and save it to %Windir%\CCM\Inventory\Noidmifs -folder"
# Create the inventory results to MIF -file and save it to %Windir%\CCM\Inventory\Noidmifs -folder
$outfile="$env:windir\CCM\Inventory\Noidmifs\MobileBroadband.mif"
If (Test-Path $outfile) {
Write-LogEntry "Previous file exist. Let's remove it!"
Remove-Item $outfile -Force
}
'Start Component' | Out-File $outfile -Encoding default -Append
'Name = "System_InformationInventory"' | Out-File $outfile -Encoding default -Append
'Start Group' | Out-File $outfile -Encoding default -Append
'Name = "MobileBroadband_Information"' | Out-File $outfile -Encoding default -Append
'ID = 1' | Out-File $outfile -Encoding default -Append
'Class = "SIM_ICCID"' | Out-File $outfile -Encoding default -Append
'Start Attribute' | Out-File $outfile -Encoding default -Append
'Name = "SIM_ICCID"' | Out-File $outfile -Encoding default -Append
'ID = 1' | Out-File $outfile -Encoding default -Append
'Type = String(80)' | Out-File $outfile -Encoding default -Append
'Value = "'+$ICCID+'"' | Out-File $outfile -Encoding default -Append
'End Attribute' | Out-File $outfile -Encoding default -Append
'Start Attribute' | Out-File $outfile -Encoding default -Append
'Name = "Provider_name"' | Out-File $outfile -Encoding default -Append
'ID = 2' | Out-File $outfile -Encoding default -Append
'Type = String(80)' | Out-File $outfile -Encoding default -Append
'Value = "'+$ProviderName+'"' | Out-File $outfile -Encoding default -Append
'End Attribute' | Out-File $outfile -Encoding default -Append
'End Group' | Out-File $outfile -Encoding default -Append
'End Component' | Out-File $outfile -Encoding default -Append
Write-LogEntry "MIF -file (MobileBroadband.mif) created to %Windir%\CCM\Inventory\Noidmifs -folder. Bye!"
Write-LogEntry "******** Script Ended ********" -ForegroundColor cyan

NOTE! Make sure you check the language you use, since if you use some other base language than English the returned value are in that language. Modify the script to language in use.

This PowerShell needs to be run on the client machine, so you can either make it run time to time on the machine with SCCM or you can set up a Task Schedule on the client machine to run the script.

Now the client side configuration is completed.

 Step 3: Processing the Hardware Inventory with NOIDMIF data

  1. Run the “Machine Policy Retrieval and Evaluation Cycle” on the client so the new policies regarding the new Hardware Inventory Classes are be received.
  2. Run the “Hardware Inventory Cycle” on the client to send the new Inventory with NOIDMIF’s data. InventoryAgent.log will show that four new attributes regarding the Class “SIM_ICCID” need to be collected for hardware Inventory data and that info needs to be sent to server.9The next line will show that “MobileBroadband_InformationInventory” does not exist, but you can ignore it.
  3. Now the XML file from the client computer will be received by MP_Hinv and processed into a MIF file and sent to the SMS_INVENTORY_DATA_LOADER component (dataldr.box) for processing.

MP_Hinv.log: 10

  1. The SMS_INVENTORY_DATA_LOADER component will receive file MIF file, process it, and then insert the data into the corresponding tables in the ConfigMgr database by running SQL stored procedures in the background.

NOTE To view the stored procedures you must enable verbose logging for the SMS_INVENTORY_DATA_LOADER component.

Dataldr.log: 11

  1. In the ConfigMgr console, open Resource Explorer for the client computer and view the Processed NOIDMIF information. You will find a new component named “MobileBroadband_Information” with its Attributes and their values under HARDWARE. Since my virtual machine doesn’t have SIM card the result is as below:

12

NOTE All of the above results and screens shots are from my lab environment setup in a simple ConfigMgr v1610 configuration. It is recommended that you perform these steps in a test environment before implementing in a production environment.

Additional Information

  1. NOIDMIF files themselves are not sent to the site server during a client hardware inventory cycle. The information that is contained within the NOIDMIF file is collected and added to the client inventory report.
  2. When you create a NOIDMIF file, this must be saved in an ANSI encoded format. NOIDMIF files saved in UTF-8 encoded format cannot be read by Configuration Manager.
  3. The Configuration.mof file is used to define the data classes to be inventoried by the hardware inventory client agent. Data classes can be created to inventory existing or custom WMI repository data classes or registry keys present on client systems.
  4. The SMS_def.mof file defines the reporting classes used by the hardware inventory client agent to determine whether or not specific client data class information is reported. Reporting classes are based on the WMI repository data classes and attributes of those classes existing on clients by default or added to them by customizing the Configuration.mof file.
  5. For more information on how to extend hardware inventory in System Center Configuration Manager please see the following: Extend hardware inventory – Configuration Manager | Microsoft Docs
  6. For more information on how to import Hardware Inventory class please see the following: Customizing Hardware Inventory in Configuration Manager 2007 using NOIDMIF Files – Microsoft Tech Community

-Niku-