Private/OSB-Drivers.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function OSB-Drivers {
    [CmdletBinding()]
    PARAM ()
    Write-Host '========================================================================================' -ForegroundColor DarkGray
    Write-Host "Install.wim: Task Drivers"    -ForegroundColor Green
    if ($Drivers) {
        foreach ($Driver in $Drivers) {
            Write-Host "$OSBuilderContent\$Driver" -ForegroundColor DarkGray
            if ($OSMajorVersion -eq 6) {
                dism /Image:"$MountDirectory" /Add-Driver /Driver:"$OSBuilderContent\$Driver" /Recurse /ForceUnsigned /LogPath:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-DISM-Task-Driver.log"
            } else {
                Add-WindowsDriver -Driver "$OSBuilderContent\$Driver" -Recurse -Path "$MountDirectory" -ForceUnsigned -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Task-Driver.log" | Out-Null
            }
        }
    } else {
        Write-Host "No Task Drivers were processed" -ForegroundColor DarkGray
    }
    
    Write-Host '========================================================================================' -ForegroundColor DarkGray
    Write-Host "Install.wim: Template Drivers"    -ForegroundColor Green

    $AOSBDrivers = @()
    $AOSBDrivers = Get-ChildItem ("$OSBuilderTemplates\Drivers\AutoApply\Global\*","$OSBuilderTemplates\Drivers\AutoApply\Global $OSArchitecture\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
    if ($OSVersionNumber -eq 7601) {
        [array]$AOSBDrivers += Get-ChildItem ("$OSBuilderTemplates\Drivers\AutoApply\Windows 7\*","$OSBuilderTemplates\Drivers\AutoApply\Windows 7 $OSArchitecture\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
    } else {
        if ($OSInstallationType -eq 'Client') {
            [array]$AOSBDrivers += Get-ChildItem ("$OSBuilderTemplates\Drivers\AutoApply\Windows 10\*","$OSBuilderTemplates\Drivers\AutoApply\Windows 10 $OSArchitecture\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
            #[array]$AOSBDrivers += Get-ChildItem ("$OSBuilderTemplates\Drivers\AutoApply\Windows 10\*","$OSBuilderTemplates\Drivers\AutoApply\Windows 10 $OSArchitecture\*","$OSBuilderTemplates\Drivers\AutoApply\Windows 10 $OSArchitecture $OSVersionNumber\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
        } else {
            [array]$AOSBDrivers += Get-ChildItem "$OSBuilderTemplates\Drivers\AutoApply\Windows Server\*" | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
            #[array]$AOSBDrivers += Get-ChildItem ("$OSBuilderTemplates\Drivers\AutoApply\Windows Server\*","$OSBuilderTemplates\Drivers\AutoApply\Windows Server $OSVersionNumber\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
        }
    }

    if ($SkipTemplates) {$AOSBDrivers = @()}

    if ($AOSBDrivers) {
        foreach ($Driver in $AOSBDrivers) {
            Write-Host "$($Driver.FullName)" -ForegroundColor DarkGray
            if ($OSMajorVersion -eq 6) {
                dism /Image:"$MountDirectory" /Add-Driver /Driver:"$($Driver.FullName)" /Recurse /ForceUnsigned /LogPath:"$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-DISM-Template-Driver.log"
            } else {
                Add-WindowsDriver -Driver "$($Driver.FullName)" -Recurse -Path "$MountDirectory" -ForceUnsigned -LogPath "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Template-Driver.log" | Out-Null
            }
        }
    } else {
        Write-Host "No Template Drivers were processed" -ForegroundColor DarkGray
    }
}

function OSB-WinPE-Drivers {
    [CmdletBinding()]
    PARAM ()
    Write-Host '========================================================================================' -ForegroundColor DarkGray
    Write-Host "WinPE: Task WinPE Drivers" -ForegroundColor Green
    if ($WinPEDrivers) {
        foreach ($WinPEDriver in $WinPEDrivers) {
            Write-Host "$OSBuilderContent\$WinPEDriver" -ForegroundColor DarkGray
            if ($OSMajorVersion -eq 6) {
                dism /Image:"$MountWinPE" /Add-Driver /Driver:"$OSBuilderContent\$WinPEDriver" /Recurse /ForceUnsigned /LogPath:"$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-DISM-Add-Driver-WinPE.log"
                dism /Image:"$MountWinRE" /Add-Driver /Driver:"$OSBuilderContent\$WinPEDriver" /Recurse /ForceUnsigned /LogPath:"$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-DISM-Add-Driver-WinRE.log"
                dism /Image:"$MountWinSE" /Add-Driver /Driver:"$OSBuilderContent\$WinPEDriver" /Recurse /ForceUnsigned /LogPath:"$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-DISM-Add-Driver-WinSE.log"
            } else {
                Add-WindowsDriver -Path "$MountWinPE" -Driver "$OSBuilderContent\$WinPEDriver" -Recurse -ForceUnsigned -LogPath "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-WindowsDriver-WinPE.log" | Out-Null
                Add-WindowsDriver -Path "$MountWinRE" -Driver "$OSBuilderContent\$WinPEDriver" -Recurse -ForceUnsigned -LogPath "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-WindowsDriver-WinRE.log" | Out-Null
                Add-WindowsDriver -Path "$MountWinSE" -Driver "$OSBuilderContent\$WinPEDriver" -Recurse -ForceUnsigned -LogPath "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-WindowsDriver-WinSE.log" | Out-Null
            }
        }
    } else {
        Write-Host "No Task WinPE Drivers were processed" -ForegroundColor DarkGray
    }

<# Write-Host '========================================================================================' -ForegroundColor DarkGray
    Write-Host "WinPE: Template WinPE Drivers" -ForegroundColor Green
 
    $AOSBDriversWinPE = @()
    $AOSBDriversWinPE = Get-ChildItem ("$OSBuilderTemplates\DriversWinPE\AutoApply\Global\*","$OSBuilderTemplates\DriversWinPE\AutoApply\Global $OSArchitecture\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
    if ($OSVersionNumber -eq 7601) {
        [array]$AOSBDriversWinPE += Get-ChildItem ("$OSBuilderTemplates\DriversWinPE\AutoApply\WinPE 3\*","$OSBuilderTemplates\DriversWinPE\AutoApply\WinPE 3 $OSArchitecture\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
    } else {
        if ($OSInstallationType -eq 'Client') {
            [array]$AOSBDriversWinPE += Get-ChildItem ("$OSBuilderTemplates\DriversWinPE\AutoApply\WinPE 10\*","$OSBuilderTemplates\DriversWinPE\AutoApply\WinPE 10 $OSArchitecture\*","$OSBuilderTemplates\DriversWinPE\AutoApply\WinPE 10 $OSArchitecture $OSVersionNumber\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
        } else {
            [array]$AOSBDriversWinPE += Get-ChildItem ("$OSBuilderTemplates\DriversWinPE\AutoApply\WinPE Server\*","$OSBuilderTemplates\DriversWinPE\AutoApply\WinPE Server $OSVersionNumber\*") | Where-Object {$_.PSIsContainer -eq $true} | Select-Object -Property FullName
        }
    } #>

}