Private/New-OSDDriverTask.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
function New-OSDDriverTask {
    [CmdletBinding()]
    Param (
        [Parameter(Mandatory)]
        [string]$OSDDriverFile,
        [string]$OSDGroup = 'Custom',
        [string]$DriverVersion = '1.0',

        [ValidateSet('x64','x86')]
        [string[]]$OsArch,

        [ValidateSet('6.1','6.2','6.3','10.0')]
        [string[]]$OsVersion,

        [string[]]$Make,

        [string[]]$Model
    )

    Begin {}

    Process {
        #===================================================================================================
        # Generate Task
        #===================================================================================================
        try {
            $OSDDriver = Get-Item "$OSDDriverFile" -ErrorAction Stop | Select-Object -Property *
        }
        catch {
            Write-Error "Could not find the OSDDriver at $OSDDriver" -ErrorAction Stop
            Break
        }

        $DriverName = $OSDDriver.BaseName
        $drvpackFile = "$DriverName.drvpack"
        
        $DriverTaskFullName = Join-Path "$($OSDDriver.DirectoryName)" "$drvpackFile"
        #===================================================================================================
        # Defaults
        #===================================================================================================
        $OSDVersion = $(Get-Module -Name OSDDrivers | Sort-Object Version | Select-Object Version -Last 1).Version
        $LastUpdate = [datetime] $(Get-Date)
        $OSDStatus = $null
        $OSDType = 'Driver'
        #$OSDGroup = 'Custom'

        #$DriverName = ''
        #$DriverVersion = $null
        $DriverReleaseId = $null
        $DriverGrouping = $null

        #$OperatingSystem = @()
        #$OsVersion = @()
        #$OsArch = @()
        #$OsBuildMax = @()
        #$OsBuildMin = @()
        $Make = @()
        if ($DriverName -match 'Dell') {$Make = 'Dell'}
        $MakeNe = @()
        $MakeLike = @()
        $MakeNotLike = @()
        $MakeMatch = @()
        $MakeNotMatch = @()

        $Generation = $null
        $SystemFamily = $null

        $Model = @()
        $ModelNe = @()
        $ModelLike = @()
        $ModelNotLike = @()
        $ModelMatch = @()
        $ModelNotMatch = @()

        $SystemSku = @()
        $SystemSkuNe = @()

        $DriverBundle = $null
        $DriverWeight = 100

        $DownloadFile = $null
        $SizeMB = $null
        $DriverUrl = $null
        $DriverInfo = $null
        $DriverDescription = $null
        $Hash = $null
        $OSDGuid = $(New-Guid)
        #===================================================================================================
        # Task
        #===================================================================================================
        $Task = [ordered]@{
            OSDVersion              = [string] $OSDVersion
            LastUpdate              = [datetime] $LastUpdate
            OSDStatus               = [string] $OSDStatus
            OSDType                 = [string] $OSDType
            OSDGroup                = [string] $OSDGroup

            DriverName              = [string] $DriverName
            DriverVersion           = [string] $DriverVersion
            #DriverReleaseId = [string] $DriverReleaseID

            #OperatingSystem = [array] $OperatingSystem
            OsVersion               = [string] $OsVersion
            OsArch                  = [array[]] $OsArch
            #OsBuildMax = [string] $OsBuildMax
            #OsBuildMin = [string] $OsBuildMin

            Make                    = [array[]] $Make
            #MakeNe = [array[]] $MakeNe
            #MakeLike = [array[]] $MakeLike
            #MakeNotLike = [array[]] $MakeNotLike
            #MakeMatch = [array[]] $MakeMatch
            #MakeNotMatch = [array[]] $MakeNotMatch

            #Generation = [string] $Generation
            #SystemFamily = [string] $SystemFamily

            #Model = [array[]] $Model
            #ModelNe = [array[]] $ModelNe
            #ModelLike = [array[]] $ModelLike
            #ModelNotLike = [array[]] $ModelNotLike
            #ModelMatch = [array[]] $ModelMatch
            #ModelNotMatch = [array[]] $ModelNotMatch

            #SystemSku = [array[]] $SystemSku
            #SystemSkuNe = [array[]] $SystemSkuNe

            #DriverGrouping = [string] $DriverGrouping
            #DriverBundle = [string] $DriverBundle
            #DriverWeight = [int] $DriverWeight

            #DownloadFile = [string] $DownloadFile
            #SizeMB = [int] $SizeMB
            #DriverUrl = [string] $DriverUrl
            #DriverInfo = [string] $DriverInfo
            #DriverDescription = [string] $DriverDescription
            #Hash = [string] $Hash
            OSDGuid                 = [string] $OSDGuid
        }
        #===================================================================================================
        # Complete
        #===================================================================================================
        Write-Host "Generating $DriverTaskFullName ..." -ForegroundColor DarkGray
        $Task | ConvertTo-Json | Out-File "$DriverTaskFullName"
        $Task
    }

    End {}
}