Public/New-OSBUpdate.ps1

<#
.SYNOPSIS
Creates a new OSBuilder Update Catalog XML
 
.DESCRIPTION
Creates a new OSBuilder Update Catalog XML for use with Get-OSBUpdate
 
.LINK
https://www.osdeploy.com/osbuilder/docs/functions/updates/new-osbupdate
 
.PARAMETER Category
Category of the Update
 
.PARAMETER Description
Description of the Update
 
.PARAMETER Category
Category of the Update
 
.PARAMETER KBNumber
KB Number of the Update
 
.PARAMETER OS
Operating System the Update applies to
 
.PARAMETER OSArch
Operating System Architecture the Update applies to
 
.PARAMETER OSBuild
Operating System Build Number the Update applies to
 
.PARAMETER ReleaseDay
Day of the Release
 
.PARAMETER ReleaseMonth
Month of the Release
 
.PARAMETER ReleaseYear
Year of the Release
 
.PARAMETER URL
Download link of the Update
 
.PARAMETER WinPE
Apply the Update to WinPE (Windows 7 only)
#>

function New-OSBUpdate {
    [CmdletBinding()]
    PARAM (
        [Parameter(Mandatory)]
        [ValidateSet('Adobe','Component','Cumulative','Servicing','Setup','Windows 7 x64 7601','Windows 7 x86 7601')]
        [string]$Category,

        [Parameter(Mandatory)]
        [string]$Description,
        
        [Parameter(Mandatory)]
        [int]$KBNumber,

        [Parameter(Mandatory)]
        [ValidateSet('Windows 10','Windows Server 2016','Windows Server 2019','Windows 7')]
        [string]$OS,

        [Parameter(Mandatory)]
        [ValidateSet('x64','x86')]
        [string]$OSArch,

        [Parameter(Mandatory)]
        [ValidateSet('1507','1511','1607','1703','1709','1803','1809','7601')]
        [string]$OSBuild,

        [Parameter(Mandatory)]
        [ValidateSet('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31')]
        [string]$ReleaseDay,
        
        [Parameter(Mandatory)]
        [ValidateSet('01','02','03','04','05','06','07','08','09','10','11','12')]
        [string]$ReleaseMonth,

        [Parameter(Mandatory)]
        [ValidateSet('2019','2018','2017','2016','2015','2014','2013','2012','2011')]
        [string]$ReleaseYear,

        [Parameter(Mandatory)]
        [string]$URL,

        [switch]$WinPE
    )

    BEGIN {
        #Write-Host '========================================================================================' -ForegroundColor DarkGray
        #Write-Host "$($MyInvocation.MyCommand.Name) BEGIN" -ForegroundColor Green

        #===================================================================================================
        Write-Verbose '19.1.1 Initialize OSBuilder'
        #===================================================================================================
        Get-OSBuilder -CreatePaths -HideDetails
    }

    PROCESS {
        Write-Host '========================================================================================' -ForegroundColor DarkGray
        Write-Host "$($MyInvocation.MyCommand.Name) PROCESS" -ForegroundColor Green

        #===================================================================================================
        Write-Verbose '19.1.1 Join DateTime Property'
        #===================================================================================================
        $ReleaseDate = [datetime]::ParseExact("$ReleaseDay/$ReleaseMonth/$ReleaseYear", "dd/MM/yyyy", $null)

        #===================================================================================================
        Write-Verbose '19.1.1 Create Custom Object'
        #===================================================================================================
        $OSBUpdate = New-Object PSObject
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name Category -Value "$Category"
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name KBNumber -Value "$KBNumber"
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name KBTitle -Value "$ReleaseYear-$ReleaseMonth $Description $OS $OSBuild $OSArch KB$KBNumber"
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name KBUrl -Value "http://support.microsoft.com/help/$KBNumber"
        if ($WinPE.IsPresent) {
            Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name Severity -Value 'WinPE'
        } else {
            Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name Severity -Value 'Custom'
        }
        
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name DatePosted -Value $([datetime]"$(($ReleaseDate).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"))")
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name DateRevised -Value $([datetime]"$(($ReleaseDate).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"))")
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name DateCreated -Value $([datetime]"$(($ReleaseDate).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"))")
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name DateLastModified -Value $([datetime]"$(($ReleaseDate).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"))")
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name FileName -Value "$(Split-Path $URL -Leaf)"
        Add-Member -InputObject $OSBUpdate -MemberType NoteProperty -Name URL -Value "$URL"

        #===================================================================================================
        Write-Verbose '19.1.1 Create OSBuilder Update Category Directory'
        #===================================================================================================
        if (!(Test-Path "$OSBuilderContent\Updates\$Category")) {New-Item -Path "$OSBuilderContent\Updates\$Category" -ItemType Directory -Force | Out-Null}

        #===================================================================================================
        Write-Verbose '19.1.1 Create OSBuilder Update Catalog'
        #===================================================================================================
        $OSBUpdate | Export-Clixml -Path "$OSBuilderContent\Updates\$Category\Catalog $Category $ReleaseYear-$ReleaseMonth $Description $OS $OSBuild $OSArch KB$KBNumber.xml"
    }

    END {
        #Write-Host '========================================================================================' -ForegroundColor DarkGray
        #Write-Host "$($MyInvocation.MyCommand.Name) END" -ForegroundColor Green
    }
}