winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

InSandboxScript.ps1 (3543B)


      1 Param(
      2   [String] $DesktopAppInstallerPath,
      3   [String[]] $DesktopAppInstallerDependencyPath,
      4   [String] $PackageIdentifier,
      5   [String] $SourceName,
      6   [String] $OutputPath,
      7   [Switch] $UseDev,
      8   [Switch] $MetadataCollection,
      9   [String] $System32Path
     10 )
     11 
     12 function Get-ARPTable {
     13   $registry_paths = @('HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKCU:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
     14   return Get-ItemProperty $registry_paths -ErrorAction SilentlyContinue | 
     15        Select-Object DisplayName, DisplayVersion, Publisher, @{N='ProductCode'; E={$_.PSChildName}} |
     16        Where-Object {$null -ne $_.DisplayName }
     17 }
     18 
     19 $ProgressPreference = 'SilentlyContinue'
     20 
     21 $desktopPath = "C:\Users\WDAGUtilityAccount\Desktop"
     22 
     23 $regFilesDirPath = Join-Path $desktopPath "RegFiles"
     24 
     25 if (Test-Path $regFilesDirPath)
     26 {
     27   foreach ($regFile in (Get-ChildItem $regFilesDirPath))
     28   {
     29 
     30     Write-Host @"
     31 --> Importing reg file $($regFile.FullName)
     32 "@
     33     reg import $($regFile.FullName)
     34   }
     35 }
     36 
     37 Write-Host @"
     38 --> Installing WinGet
     39 
     40 "@
     41 
     42 if ($UseDev)
     43 {
     44   foreach($dependency in $DesktopAppInstallerDependencyPath)
     45   {
     46     Write-Host @"
     47   ----> Installing $dependency
     48 "@
     49     Add-AppxPackage -Path $dependency
     50   }
     51 
     52   Write-Host @"
     53   ----> Enabling dev mode
     54 "@
     55   reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
     56 
     57   $devPackageManifestPath = Join-Path $desktopPath "DevPackage\AppxManifest.xml"
     58   Write-Host @"
     59   ----> Installing $devPackageManifestPath
     60 "@
     61   Add-AppxPackage -Path $devPackageManifestPath -Register
     62 }
     63 else
     64 {
     65   Install-PackageProvider -Name NuGet -Force | Out-Null
     66   Install-Module Microsoft.WinGet.Client -Force | Out-Null
     67   Repair-WingetPackageManager -Latest
     68 }
     69 
     70 $originalARP = Get-ARPTable
     71 
     72 Write-Host @"
     73 
     74 --> Installing $PackageIdentifier
     75 
     76 "@
     77 
     78 $installAndCorrelateOutPath = Join-Path $OutputPath "install_and_correlate.json"
     79 
     80 $installAndCheckCorrelationExe = Join-Path $desktopPath "InstallAndCheckCorrelation\InstallAndCheckCorrelation.exe"
     81 $installAndCheckCorrelationArgs = @('-id', $PackageIdentifier, '-src', $SourceName, '-out', $installAndCorrelateOutPath)
     82 
     83 if ($UseDev)
     84 {
     85   $installAndCheckCorrelationArgs += '-dev'
     86 }
     87 
     88 if ($MetadataCollection)
     89 {
     90   $wingetUtilPath = Join-Path $PSScriptRoot "WinGetUtil.dll"
     91   $installAndCheckCorrelationArgs += ('-meta', $wingetUtilPath, '-sys32', $System32Path)
     92 }
     93 
     94 & $installAndCheckCorrelationExe $installAndCheckCorrelationArgs
     95 
     96 Write-Host @"
     97 
     98 --> Copying logs
     99 "@
    100 
    101 if ($UseDev)
    102 {
    103   Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\WinGetDevCLI_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
    104 }
    105 else
    106 {
    107   Copy-Item -Recurse (Join-Path $env:LOCALAPPDATA "Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir") $OutputPath
    108 }
    109 
    110 
    111 Write-Host @"
    112 
    113 --> Comparing ARP Entries
    114 "@
    115 
    116 $arpCompared = (Compare-Object (Get-ARPTable) $originalARP -Property DisplayName,DisplayVersion,Publisher,ProductCode)
    117 $arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table
    118 
    119 $arpCompared | Select-Object -Property * -ExcludeProperty SideIndicator | Format-Table | Out-File (Join-Path $OutputPath "ARPCompare.txt")
    120 
    121 "Done" | Out-File (Join-Path $OutputPath "done.txt")