forked from microsoft/msquic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxdp-install.ps1
More file actions
73 lines (63 loc) · 2.28 KB
/
Copy pathxdp-install.ps1
File metadata and controls
73 lines (63 loc) · 2.28 KB
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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
<#
.Synopsis
Install (or uninstall) XDP on Windows.
.Parameter Destination
The installation path of XDP.
.Parameter Uninstall
Uninstall XDP if installed. If not set, install XDP.
.EXAMPLE
Invoke this script directly from the web
iex "& { $(irm https://aka.ms/xdp-install) }"
#>
param(
[Parameter(Mandatory = $false)]
[string] $Destination = ".\",
[Parameter(Mandatory = $false)]
[switch] $Uninstall,
[Parameter(Mandatory = $false)]
[switch] $SkipCerts
)
#Requires -RunAsAdministrator
Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$NetworkPath = (irm "https://raw.githubusercontent.com/microsoft/msquic/main/scripts/xdp-devkit.json").path
$ZipPath = Join-Path $Destination "xdp.zip"
$XdpPath = Join-Path $Destination "xdp"
$XdpInstalled = Test-Path "$XdpPath\bin\xdp.inf"
if (!$Uninstall) {
# Clean up any previous install. Don't delete the old directory as it might
# contain some other non-XDP files.
if ($XdpInstalled) {
Write-Output "Uninstalling old XDP driver"
try {
netcfg.exe -u ms_xdp
pnputil.exe /delete-driver "$XdpPath\bin\xdp.inf"
} catch { }
}
# Download and extract the latest version of the XDP kit (overwriting as
# necessary).
Write-Host "Downloading and extracting $NetworkPath"
Invoke-WebRequest -Uri $NetworkPath -OutFile $ZipPath
Expand-Archive -Path $ZipPath -DestinationPath $XdpPath -Force
Remove-Item -Path $ZipPath
if (!$SkipCerts) {
# Install the certificates to the necessary stores.
Write-Host "Installing certificates"
CertUtil.exe -addstore Root "$XdpPath\bin\CoreNetSignRoot.cer"
CertUtil.exe -addstore TrustedPublisher "$XdpPath\bin\CoreNetSignRoot.cer"
}
# Install the XDP driver.
Write-Host "Installing XDP driver"
netcfg.exe -l "$XdpPath\bin\xdp.inf" -c s -i ms_xdp
} elseif ($XdpInstalled) {
# Uninstall the XDP driver and delete the folder.
Write-Output "Uninstalling XDP driver"
try {
netcfg.exe -u ms_xdp
pnputil.exe /delete-driver "$XdpPath\bin\xdp.inf"
} catch { }
Remove-Item -Path $XdpPath -Recurse -Force
}