Blog Post

SCCM - Software Inventory Import Script

Dujon Walsham • Oct 05, 2018

This was a script which I wrote up that can automate adding files and file types which can be added into the Software Inventory using the SCCM SDK script

How the script works

If you have a list of files and file extensions and with wildcards etc.. The script will be able to format the list into the SCCM SDK and create a new client settings configuration and apply the files and file extensions in which will be added to the Software Inventory section.

If the client settings configuration does not exist then it will create it.

Variables to take note of

·$SiteCode – Site code of your SCCM environment

·$File – Location of the list of files and file extensions

·$ClientSettingsName – Name of the client settings which the Software Inventory settings will be updated on

Script

Below is the script


#

#

# Software Inventory Settings Import

# By Dujon Walsham

#

#

#

#

#

#######################################################


# Variables

$SiteCode = "" # Site Code for you SCCM Architecture

$SiteCodeLocation = $SiteCode + ":"

$Computername = $env:COMPUTERNAME

$File = "" # Location for your files which contains the filenames you want to add to the inventory

$Namespace = "root\sms\site_$Sitecode" # Namespace to access your SCCM SDK

$ClientSettingsName = "" # Name for the client settings you want to create


# Connect to SCCM

Import-Module -Name "$(Split-Path $env:SMS_ADMIN_UI_PATH)\ConfigurationManager.psd1"

Set-Location $SiteCodeLocation


# Structure Inventory Files

$Files = Import-Csv $File -Header Files

$Search = $files.Count

$inventoriabletypes = $files.files -join " " -split " "

$AllTrue = "True " * $Search -split " "

$AllPath = "* " * $Search -split " "

$AllTruelines = $AllTrue.count -2

$AllPathLines = $AllPath.count -2

$AllTrue = $AllTrue[0..$AllTruelines]

$AllPath = $AllPath[0..$AllPathLines]


$Settings = Get-CimInstance -ComputerName $Computername -Namespace $Namespace -ClassName SMS_ClientSettings | Where-Object {$_.Name -eq $ClientSettingsName}


If ($Settings -eq $null)

{New-CMClientSetting -Name $ClientSettingsName -Type Device}


$Settings = Get-CimInstance -ComputerName $Computername -Namespace $Namespace -ClassName SMS_ClientSettings | Where-Object {$_.Name -eq $ClientSettingsName}



# Create Software Inventory Settings


$InventorySettings = New-CimInstance -ClientOnly `

-Namespace $Namespace `

-ClassName "SMS_SoftwareInventoryAgentConfig" `

-Property @{AgentID=[uint32]'2';

Enabled=[boolean]$true;

Exclude=[String[]]($AllTrue);

ExcludeWindirAndSubfolders=[string[]]($AllTrue);

InventoriableTypes=[string[]]($inventoriabletypes);

Path=[string[]]($AllPath);

ReportOptions=[uint32]'7';

Schedule='0001200000100038';

SubDirectories=[string[]]($AllTrue)}


$Settings.AgentConfigurations += $InventorySettings


# Apply Software Inventory Settings


Get-CimInstance -ComputerName $Computername -Namespace $Namespace -ClassName SMS_ClientSettings | Where-Object {$_.Name -eq $ClientSettingsName} | Set-CimInstance -Property @{AgentConfigurations=$Settings.AgentConfigurations}






by D Walsham 13 Dec, 2021
Looking through the current SQL Server topology and how it affects our decision
by D Walsham 07 Oct, 2021
Introduction
by D Walsham 06 Oct, 2021
Introduction
by D Walsham 12 Aug, 2021
All the parts of the series we went into great detail about how we analyse an end to end solution and how we would design a solution in which would allow us to build endpoints without SCCM being a dependency. Whilst we did this, there is another scenario which we have not touched on yet, which is the hybrid scenarios. In a perfect world ideally you would have your Azure Active Directory within the cloud, every machine meets the recommended requirements for Windows 10, everything is imported into Intune/Autopilot and everyone is happy. But we know this isn't realistic in all cases. Many organisations cannot just simply up and go from on-premise into the cloud therefore the checkpoint here is of course getting into hybrid solutions such as; Co-Management Between Intune and SCCM Hybrid AD with Azure AD and On-Premise AD syncing together These things can play a very interesting part in how you would tackle this if you envisage the next step in the blueprint is to be in a position in which you can build and manage endpoints soley within Intune. With this final part of the series we will go in-depth in how the common hybrid setups look like and how we go about moving into the next step of being able to manage and build devices without SCCM.
by D Walsham 29 Jul, 2021
In continuation from the previous part where we had discussed how we create the "on site" piece of the solution, this was the part which would allow us to get our endpoints into a state in which they would essentially be ready to go through the Autopilot process. Which leaves our next piece of the puzzle, to begin the configuration of the actual backend side that resides within our Endpoint Management console. And you will see how everything ties up together to satisfy the full end to end process of getting an unknown (or known) device to proceed thorough the whole workflow to be finally managed by Intune without the aid of SCCM taking part in any of the prerequisites or preparation at hand.
by D Walsham 15 Jul, 2021
In this part we are now going to look into the technical step by step points on how we put everything together. In the previous part we spoke about the structure of how we would asses whether a machine was actually ready to be built with Autopilot or not with a build checklist process which would step through all areas which would cover an endpoints eligibility. Now with everything planned out we finally want to step into making things reality by putting everything together.
by D Walsham 02 Jul, 2021
When it comes to managing your endpoints in endpoint manager, one of the things you may be looking to do is to get all of your Intune registered machines to also be enrolled as Autopilot devices. Now we can of course just have the deployment profile deployed to all machines and then hit the "Convert targeted machines to autopilot" but this might not necessarily be feasible for every client. We may want to perform some due diligence first so we can at least understand what devices in Intune are not in Autopilot.
Show More
Share by: