[REQ] Scan folder to create selection profiles, $OS - $MAKE - $MODEL

Discussion in 'Scripting' started by hypedave, Dec 6, 2014.

  1. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    #1 hypedave, Dec 6, 2014
    Last edited by a moderator: Apr 20, 2017
    Ok here we go

    Here is my current Driver Repository folder structure. Within it there are multiple makes & models. For this example i'm only going to narrow it down to just one vendor.

    Code:
    D:\DriverStore
    D:\DriverStore\Windows 7 x64
    D:\DriverStore\Windows 7 x64\Dell Inc
    D:\DriverStore\Windows 7 x64\Dell Inc\Optiplex 780
    D:\DriverStore\Windows 7 x86
    D:\DriverStore\Windows 7 x86\Dell Inc
    D:\DriverStore\Windows 7 x86\Dell Inc\Optiplex 760
    D:\DriverStore\Windows 8 x64
    D:\DriverStore\Windows 8 x64\Dell Inc
    D:\DriverStore\Windows 8 x64\Dell Inc\Optiplex 3010
    D:\DriverStore\Windows 8 x86
    D:\DriverStore\Windows 8 x86\Dell Inc
    D:\DriverStore\Windows 8 x86\Dell Inc\Optiplex 3020
    D:\DriverStore\Windows 8.1 x64
    D:\DriverStore\Windows 8.1 x64\Dell Inc
    D:\DriverStore\Windows 8.1 x64\Dell Inc\Optiplex 9020 AIO
    D:\DriverStore\Windows 8.1 x86
    D:\DriverStore\Windows 8.1 x86\Dell Inc
    D:\DriverStore\Windows 8.1 x86\Dell Inc\Tablet 5130
    I need a script that will convert the folder structure above to this
    D:\DriverStore\$OS\$Make\$Model
    
    and then execute the following powershell script;
    Current powershell command to create driver selection profiles

    Code:
    Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
    New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "E:\DeploymentShare"
    new-item -path "DS001:\Selection Profiles" -enable "True" -Name "Drivers - Windows 7 x64 - Dell Inc - Optiplex 380" -Comments "" -Definition "<SelectionProfile><Include path=`"Out-of-Box Drivers\Windows 7 x64\Dell Inc\Optiplex 380`" /></SelectionProfile>" -ReadOnly "False" -Verbose
    Command I would like to use based on variables

    Code:
    Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
    New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "E:\DeploymentShare"
    new-item -path "DS001:\Selection Profiles" -enable "True" -Name "Drivers - $OS - $MAKE - $MODEL" -Comments "" -Definition "<SelectionProfile><Include path=`"Out-of-Box Drivers\$OS\$MAKE\$MODEL`" /></SelectionProfile>" -ReadOnly "False" -Verbose
    Code:
    ::===============================================================================================================
    :: Path to Windows 7 x64 Make & Model Driver Store
    set drivers1=d:\driverstore\Windows 7 x64
    :: Path to Windows 8 x64 Make & Model Driver Store
    set drivers2=d:\driverstore\Windows 7 x86
    :: Path to Windows 8 x64 Make & Model Driver Store
    set drivers3=d:\driverstore\Windows 8 x64
    :: Path to Windows 8 x86 Make & Model Driver Store
    set drivers4=d:\driverstore\Windows 8 x86
    :: Path to Windows 8.1 x64 Make & Model Driver Store
    set drivers5=d:\driverstore\Windows 8.1 x64
    :: Path to Windows 8.1 x86 Make & Model Driver Store
    set drivers6=d:\driverstore\Windows 8.1 x86
    ::===============================================================================================================
    
    
     
  2. s1ave77

    s1ave77 Has left at his own request

    Aug 15, 2012
    16,093
    24,397
    340
    Nice idea, since one can use powershell directly or as hybrid from within any cmd file :good3:.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. hypedave

    hypedave MDL Member

    Oct 14, 2014
    129
    30
    10
    This has been resolved now. I used regular command line prompt. Just need to clean up the code some more.