Public/New-OSDUpdateRepository.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
<#
.SYNOPSIS
Creates an OSDUpdate Repository
 
.DESCRIPTION
Creates an OSDUpdate Repository to store downloaded updates
 
.LINK
https://www.osdeploy.com/osdupdate/docs/functions/new-osdupdaterepository
 
.PARAMETER Catalog
The Microsoft Office or Windows Update Catalog to store
 
.PARAMETER RepositoryRootPath
Full Path of the OSDUpdate Repository
 
.EXAMPLE
New-OSDUpdateRepository -Catalog 'Windows 10 x64' -RepositoryRootPath "C:\OSDUpdate"
Creates an OSDUpdate Repository in C:\OSDUpdate
Creates a directory C:\OSDUpdate\Windows 10 x64 with an initial Update Catalog
#>

function New-OSDUpdateRepository {
    [CmdletBinding()]
    PARAM (
        [Parameter(Mandatory = $True)]
        [ValidateSet(
            'Office 2010 32-Bit',
            'Office 2010 64-Bit',
            'Office 2013 32-Bit',
            'Office 2013 64-Bit',
            'Office 2016 32-Bit',
            'Office 2016 64-Bit',
            'Windows 7 x86',
            'Windows 7 x64',
            'Windows 10 x86',
            'Windows 10 x64',
            'Windows Server 2012 R2 x64',
            'Windows Server 2016 x64',
            'Windows Server 2019 x64')]
            [string]$Catalog,
            
        [Parameter(Mandatory = $True)]
        [string]$RepositoryRootPath

    )
    if (!(Test-Path "$RepositoryRootPath")) {New-Item -Path "$RepositoryRootPath" -ItemType Directory -Force | Out-Null}
    if (!(Test-Path "$RepositoryRootPath\$Catalog")) {New-Item -Path "$RepositoryRootPath\$Catalog" -ItemType Directory -Force | Out-Null}
    Copy-Item -Path "$($MyInvocation.MyCommand.Module.ModuleBase)\Catalogs\OSDUpdate $Catalog.xml" -Destination "$RepositoryRootPath\$Catalog" -Force | Out-Null
}