none
Manage MDT drivers in powershell - move drivers for specific platform

    Question

  • I imported a lot of drivers into MDT using powershell into properly configured folder scheme (depending on model, manufacturer and architecture). Now I need to move all drivers

     

    for platform x86 into proper folder. When I try

    Get-ChildItem -Path "DS001:\Out-of-Box Drivers\Win7_x64\Hewlett-Packard\HP Compaq Elite 8300 SFF" -Recurse |where {$_.Platform -eq "x86"} | sort-object Platform | ft -Property Source, Platform -GroupBy Platform -autosize

    it shows me drivers for x86 and {x86, ia64} platform:

    Source                                                                                           Platform
    ------                                                                                           --------
    .\Out-of-box Drivers\Net\E1C6232_11.15.16.0_80C5F5ECB2951F6C20A684E86C0F1DB1DC4B855C\E1C6232.INF {x86}


       Platform: {x86, ia64}

    Source                                                                                          Platform
    ------                                                                                          --------
    .\Out-of-box Drivers\Net\e1000325_8.10.3.0_E7E8B8D35EAEC8358D0E6181C6F8B02B6159A361\e1y5132.inf {x86, ia64}

    And I need move drivers only for x86 platform (not both)



    • Edited by bbelko Tuesday, April 16, 2013 8:48 AM
    Tuesday, April 16, 2013 8:47 AM

Answers

  • The reason you're not getting the correct results is that platform is an Object array. Try this:

    $drivers = Get-ChildItem -Path "DS001:\Out-of-Box Drivers\Win7_x64\Hewlett-Packard\HP Compaq Elite 8300 SFF" -Recurse
    foreach ($driver in $drivers) {
        if ($driver.platform -join "`n" -eq "x86") {
            # replace write-host with your move command if the output is correct
            Write-Host Name: $driver.name, Platform: $driver.platform
        }
    }

     
    • Marked as answer by bbelko Tuesday, April 16, 2013 12:21 PM
    Tuesday, April 16, 2013 9:45 AM

All replies

  • The reason you're not getting the correct results is that platform is an Object array. Try this:

    $drivers = Get-ChildItem -Path "DS001:\Out-of-Box Drivers\Win7_x64\Hewlett-Packard\HP Compaq Elite 8300 SFF" -Recurse
    foreach ($driver in $drivers) {
        if ($driver.platform -join "`n" -eq "x86") {
            # replace write-host with your move command if the output is correct
            Write-Host Name: $driver.name, Platform: $driver.platform
        }
    }

     
    • Marked as answer by bbelko Tuesday, April 16, 2013 12:21 PM
    Tuesday, April 16, 2013 9:45 AM
  • Thanks for help. It work with Write-host very well. Can You please help me also whit actually move these drivers? I have some problems using move-item commandlet. I want to move these drivers to "DS001:\Out-of-Box Drivers\Win7_x86\Hewlett-Packard\HP Compaq Elite 8300 SFF"

    And if it is possible please send me some link where I can read about such techniques like working with Object array and -join parameter. Or how to display help in powershell regarding this?

    • Edited by bbelko Tuesday, April 16, 2013 11:02 AM
    Tuesday, April 16, 2013 11:00 AM
  • Replace the Write-Host command with this:

    (once you run it will move everything that Write-host output, so doublecheck with Write-host)

    Move-Item $driver.Name -Destination "DS001:\Out-of-Box Drivers\Win7_x86\Hewlett-Packard\HP Compaq Elite 8300 SFF"

    As for further reading, I suggest you do some Google searches for "Powershell working with arrays", "Powershell working with strings" and so on. You'll find lots of great blogs and other resources to help you.

    PS: You could also use these in your PowerShell for some info:

    help about_join
    help about_split
    help about_arrays


    Tuesday, April 16, 2013 11:29 AM
  • Using 

    Move-Item $driver.Name

    is not enough, there is an error with path:

    Move-Item : Cannot find path 'C:\Users\...\Desktop\skrypty\Renesas Electronics USB nusb3xhc.inf 2.0.20.0' because
    it does not exist.

    So I used something like below and it works now:

    $old = "DS001:\Out-of-Box Drivers\Win7_x64\Hewlett-Packard\HP Compaq Elite 8300 SFF\chipset\" + $driver.Name
    Move-Item $old -Destination "DS001:\Out-of-Box Drivers\Win7_x86\Hewlett-Packard\HP Compaq Elite 8300 SFF\chipset"

    Tuesday, April 16, 2013 12:23 PM
  • And the next problem with this is that I have subolders as You can see on attached screen shot (e.g. chipset, audio, etc.) and I want to move drivers for the same named subfolders. e.g.:

    from "DS001:\Out-of-Box Drivers\Win7_x64\Hewlett-Packard\HP Compaq Elite 8300 SFF\chipset"

    to "DS001:\Out-of-Box Drivers\Win7_x86\Hewlett-Packard\HP Compaq Elite 8300 SFF\chipset"

    and so on, I do not want to hardcode the subfolders name because the  whole script will be very long.

    Any idea?

    Tuesday, April 16, 2013 12:28 PM
  • I have working script, I create array with subfolders name and also add some copy-item function to copy drivers which are marked as for both architectures

    Add-PSSnapIn Microsoft.BDD.PSSnapIn
    New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "D:\DeploymentShare"

    $subfolders = @("audio","bluetooth","broadband","camera","chipset","ethernet","fingerprint","graphic","hotkey","smartcard","storage","touchpad","wifi","AMT")

    foreach ($s in $subfolders) {

    $p = "DS001:\Out-of-Box Drivers\Win7_x64\Hewlett-Packard\HP Compaq Elite 8300 SFF\" + $s
    $new = $p -replace 'x64','x86'

    $drivers = Get-ChildItem -Path $p
    foreach ($driver in $drivers) {
    if ($driver.platform -join "`n" -eq "x86") {
    $old = $p + "\" + $driver.Name
    Move-Item $old -Destination $new
    }
    }

    $drv = Get-ChildItem -Path $p
    foreach ($driver in $drv) {
    if ($driver.platform -eq "x86") {
    $old = $p + "\" + $driver.Name
    copy-Item $old -Destination $new

    }
    }

    }

    Tuesday, April 16, 2013 1:16 PM