commit
25dc33c758
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Function Get-WingetCmd {
|
Function Get-WingetCmd {
|
||||||
|
|
||||||
#Get WinGet Path (if admin context)
|
#Get WinGet Path (if Admin context)
|
||||||
# Includes Workaround for ARM64 (removed X64 and replaces it with a wildcard)
|
# Includes Workaround for ARM64 (removed X64 and replaces it with a wildcard)
|
||||||
$ResolveWingetPath = Resolve-Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe" | Sort-Object { [version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1') }
|
$ResolveWingetPath = Resolve-Path "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_*__8wekyb3d8bbwe" | Sort-Object { [version]($_.Path -replace '^[^\d]+_((\d+\.)*\d+)_.*', '$1') }
|
||||||
|
|
||||||
|
@ -11,16 +11,20 @@ Function Get-WingetCmd {
|
||||||
$WingetPath = $ResolveWingetPath[-1].Path
|
$WingetPath = $ResolveWingetPath[-1].Path
|
||||||
}
|
}
|
||||||
|
|
||||||
#Get Winget Location in User context
|
#If running under System or Admin context obtain Winget from Program Files
|
||||||
$WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue
|
if((([System.Security.Principal.WindowsIdentity]::GetCurrent().User) -eq "S-1-5-18") -or ($WingetPath)){
|
||||||
if ($WingetCmd) {
|
if (Test-Path "$WingetPath\winget.exe") {
|
||||||
$Script:Winget = $WingetCmd.Source
|
$Script:Winget = "$WingetPath\winget.exe"
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
#Get Winget Location in User context
|
||||||
|
$WingetCmd = Get-Command winget.exe -ErrorAction SilentlyContinue
|
||||||
|
if ($WingetCmd) {
|
||||||
|
$Script:Winget = $WingetCmd.Source
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#Get Winget Location in System context
|
|
||||||
elseif (Test-Path "$WingetPath\winget.exe") {
|
If(!($Script:Winget)){
|
||||||
$Script:Winget = "$WingetPath\winget.exe"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Write-ToLog "Winget not installed or detected !" "Red"
|
Write-ToLog "Winget not installed or detected !" "Red"
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue