PowerShell GUI: Create ConfigMgr DriverPackages v 1.0

It can be a real hassle creating new Driver Packages, especially if you want to have some order in your repository.
If you don’t want to go ‘all in’, like when you’re using the Coretech tool: this little script that I’ve created might come in handy.

The idea is pretty simple, just enter manufacturer, os and model,
and the script will then:

  • create a folder: DriverSource OS  Manufacturer  Model
  • create a folder: PackageSource OS  Manufacturer  Model
  • create a new Driver Package
  • create a new Driver Category (optional)

all with the right names and in the right location… neat huh?

 The Script

The Script reads settings from Settings.xml, located in the same folder as the script.
If it doesn’t exists, it’ll be created.

xml

The first time the script runs it will automatically go to the settings tab.
(no need to modify the xml file manually)

CreateDriverPackages_Settings

 

The What If button shows the commands that will be executed.

CreateDriverPackages_WhatIf

 

Now go ahead and create some Driver Packages 🙂

CreateDriverPackages_Done

Requirements

You need the ConfigurationManager PowerShell Module available.
If you don’t have the ConfigMgr Console installed,  you need to modify the Import-Module command.
I’m using the following line:
Import-Module ($env:SMS_ADMIN_UI_PATH.Substring(0,$env:SMS_ADMIN_UI_PATH.Length – 5) + ‘ConfigurationManager.psd1’)

The End

I’m using PowerShell Studio by Sapien to build the GUI, it really simplifies the process.
If you haven’t tried it, I really recommend that you do so.

And here’s the link to the script, it contains both the .ps1 version and the PowerShell Studio project file…

I’d really love to hear your two cents…

/Andreas

3 thoughts on “PowerShell GUI: Create ConfigMgr DriverPackages v 1.0

  • November 12, 2014 at 04:18
    Permalink

    Very nice and neat! Thank you. I’ve customized it to work with our naming standard etc. Looking to add driver import using the Driverpackage Source.

  • November 13, 2014 at 00:02
    Permalink

    I found code at jamesbannanit.com to import drivers, add to bottom of $btnCreatePackage_Click,:

    $PSD = Get-PSDrive -PSProvider CMSite
    Set-Location C:

    $Drivers = Get-ChildItem -Path $sDriverSourcePath -Include *.inf -Recurse
    CD “$($PSD):”
    $DriverPackage = Get-CMDriverPackage -Name $NewDriverPackageName
    Write-Host $sNewCategory
    $DriverCategory01 = Get-CMCategory -Name $sNewCategory
    $DriverCategories = @()
    $DriverCategories += $DriverCategory01

    # 1.4 Import Drivers
    WriteLog -text “Importing Drivers”
    foreach ($driver in $drivers)
    {
    Import-CMDriver -UncFileLocation $Driver.FullName
    -DriverPackage $DriverPackage

    -EnableAndAllowInstall $true
    -AdministrativeCategory $DriverCategories

    -ImportDuplicateDriverOption AppendCategory
    -ErrorAction SilentlyContinue

    -Verbose
    }
    WriteLog -text “Importing complete”
    }

  • November 21, 2014 at 17:39
    Permalink

    My plan was to add driver import as well, but somehow i didn’t. It turned out that it’s so much slower to use Import-CMDriver then to do it through the console, but maybe it would be possible to use PowerShell workflow to speed things up.

    I’m glad you liked it, and thank you for your suggestion for improvement!

Leave a Reply

Your email address will not be published. Required fields are marked *