-
Notifications
You must be signed in to change notification settings - Fork 5
/
MicrosoftDesktopApp.ps1
71 lines (64 loc) · 2.21 KB
/
MicrosoftDesktopApp.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
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2024 v5.8.242
Created on: 17-5-2024 16:03
Created by: Rink Turksma
Organization:
Filename: MicrosoftDesktopApp.ps1
===========================================================================
.DESCRIPTION
#Install https://github.com/microsoft/winget-cli/releases
#>
$IntunePrepToolInstallPath = 'C:\Program Files\IntunePrepTool'
Set-Location $IntunePrepToolInstallPath
$WingetMSIXPath = Join-Path -Path $IntunePrepToolInstallPath -ChildPath "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
if (!(Test-Path $WingetMSIXPath))
{
$WingetUrl = "https://github.com/microsoft/winget-cli/releases/download/v1.7.11261/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
Write-Host "Please wait; Downloading Winget-cli: https://github.com/microsoft/winget-cli/releases/download/v1.7.11261/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -ForegroundColor Green
try
{
Start-BitsTransfer -Source $WingetUrl -Destination $WingetMSIXPath -Priority High -ErrorAction Stop
}
catch
{
$_.Exception | Format-List -Force
$_.Exception.InnerException
}
if (Test-Path -Path $WingetMSIXPath)
{
Write-Host "Winget has been downloaded successfully at $WingetMSIXPath"
}
else
{
Write-Host "Winget download failed"
}
}
try
{
Add-ProvisionedAppxPackage -online -PackagePath $WingetMSIXPath -SkipLicense -ErrorAction Stop
Start-Sleep 5
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe\winget.exe"
if ($ResolveWingetPath)
{
$WingetPath = $ResolveWingetPath[-1].Path
}
$wingetexe = $ResolveWingetPath
if (Test-path $wingetexe)
{
Write-host "Installation Winget success."
Write-Host "Winget now testing and accepting-source-agreements"
& $wingetexe search rink-turksma.IntunePrepTool --accept-source-agreements
}
else
{
Write-Host "Installation Winget Failed."
}
}
catch
{
$_.Exception | Format-List -Force
$_.Exception.InnerException
Write-Host "An error occurred during the installation of Winget."
}