locked
CM-ImportDriver and Get-ChildItem RRS feed

  • Question

  • I am trying to use the CM-ImportDriver Cmdlet and running into a problem.  After I import the module, I change my site to ABC1:.  From there, I cannot use Get-ChildItem for a UNC path and the CM-ImportDriver throws an error saying it needs a valid driver to import.  That happens because it cannot access the UNC path from earlier.  If I change back to C:, then I can run Get-ChildItem with no problem.  What do I need to do in order to bridge the gap between using C: and ABC1:? 

    The CM-ImportDriver requires a UNC path to pull the stored drivers from, which is fine. However, I cannot get it to read the UNC paths provided.   Thanks in advance. 


    Best, Jacob I'm a PC.

    Friday, December 27, 2013 2:54 PM

Answers

  • Hi,

    This is taken from here Get-ChildItem - In its basic form the Get-ChildItem cmdlet provides functionality similar to the dir command. For example, if you simply type Get-ChildItem at the Windows PowerShell prompt you’ll get back information about the objects in the current location.

    For example this lists HKLM registry child items

    Set-Location HKLM:
    Get-ChildItem

    For example this lists C:\ drive child items

    Set-Location C:\
    Get-ChildItem

    For example in CM 2012 R2 it lists all the admin console nodes

    Set-Location PS1:\
    Get-ChildItem

    You need to query the driver sources before you change the connection context to your site code. For example like this

    #Step 1

    Set-Location C:\

    $Drivers = Get-childitem -path "\\cm01\Sources\OSD\Drivers\Sources\Lenovo\W7x64\T500" -Recurse -Filter "*.inf"

    #Step 2

    Set-Location PS1:\

    foreach($item in $Drivers)

    {

    Import-CMDriver -UncFileLocation $item.FullName

    }

    Best,

    Kaido

    • Proposed as answer by Kaido1000MVP Monday, December 30, 2013 7:49 AM
    • Marked as answer by Juke Chou Tuesday, December 31, 2013 3:26 AM
    Monday, December 30, 2013 7:49 AM

All replies

  • Have you used the -UncFileLocation parameter?

    There is also a script that can do this.

    http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2/

    Important Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.


    Juke Chou

    TechNet Community Support

    Sunday, December 29, 2013 4:24 PM
  • I was using the -UNCFileLocation with "\\myserver\myfiles\drivers" and I tried "\\myserver\d$\myfiles\drivers"

    When I run that from the site server drive, I get an error that the drive could not be found.  What I noticed was if I was using test-path, it worked fine as long as I was not in my site server drive. (C:)  When I changed to the site server drive, PS1:, the drive could not be found. 


    Best, Jacob I'm a PC.

    Sunday, December 29, 2013 4:59 PM
  • Hi,

    This is taken from here Get-ChildItem - In its basic form the Get-ChildItem cmdlet provides functionality similar to the dir command. For example, if you simply type Get-ChildItem at the Windows PowerShell prompt you’ll get back information about the objects in the current location.

    For example this lists HKLM registry child items

    Set-Location HKLM:
    Get-ChildItem

    For example this lists C:\ drive child items

    Set-Location C:\
    Get-ChildItem

    For example in CM 2012 R2 it lists all the admin console nodes

    Set-Location PS1:\
    Get-ChildItem

    You need to query the driver sources before you change the connection context to your site code. For example like this

    #Step 1

    Set-Location C:\

    $Drivers = Get-childitem -path "\\cm01\Sources\OSD\Drivers\Sources\Lenovo\W7x64\T500" -Recurse -Filter "*.inf"

    #Step 2

    Set-Location PS1:\

    foreach($item in $Drivers)

    {

    Import-CMDriver -UncFileLocation $item.FullName

    }

    Best,

    Kaido

    • Proposed as answer by Kaido1000MVP Monday, December 30, 2013 7:49 AM
    • Marked as answer by Juke Chou Tuesday, December 31, 2013 3:26 AM
    Monday, December 30, 2013 7:49 AM
  • That worked perfectly.  Many thanks for helping on this one.  I'm just starting to cut my teeth in Powershell.

    Best, Jacob I'm a PC.

    Monday, December 30, 2013 1:31 PM