-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUWP-Current-user-install-prompts.ps1
36 lines (30 loc) · 1.34 KB
/
UWP-Current-user-install-prompts.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
# Check for administrative rights
If (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
# Try to relaunch the script as admin
$arguments = "& '" + $myInvocation.MyCommand.Definition + "'"
Start-Process powershell.exe -ArgumentList $arguments -Verb RunAs
Exit
}
# Get the folder where the script is located
$folderPath = Split-Path -Parent $MyInvocation.MyCommand.Path
# Function to install app packages with user confirmation
function Install-AppPackages {
param ([string]$extension)
Get-ChildItem -Path $folderPath -Filter *$extension | ForEach-Object {
$response = Read-Host "Do you want to install package: $($_.Name)? (Y/N)"
if ($response -eq 'Y' -or $response -eq 'y') {
Write-Output "Installing package: $($_.Name)"
Add-AppxPackage -Path $_.FullName
} else {
Write-Output "Skipping package: $($_.Name)"
}
}
}
# Install all package types with prompt
$extensions = @(".msix", ".appx", ".msixbundle", ".appxbundle")
foreach ($extension in $extensions) {
Install-AppPackages -extension $extension
}
Write-Output "All packages processed."
# Keep the script open after completion
Read-Host "Press Enter to exit..."