-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #789 from AndrewDemski-ad-gmail-com/main
Step towards experimental group of settings in ADMX Policies
- Loading branch information
Showing
7 changed files
with
182 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
#Function to get the winget command regarding execution context (User, System...) | ||
|
||
Function Get-WingetCmd { | ||
|
||
$WingetCmd = $null | ||
[OutputType([String])] | ||
$WingetCmd = [string]::Empty; | ||
|
||
#Get WinGet Path | ||
# default winget path (in system context) | ||
[string]$ps = "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe"; | ||
|
||
#default winget path (in user context) | ||
[string]$pu = "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe"; | ||
|
||
try { | ||
#Get Admin Context Winget Location | ||
$WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw | ||
$WingetInfo = (Get-Item -Path $ps).VersionInfo | Sort-Object -Property FileVersionRaw -Descending | Select-Object -First 1; | ||
#If multiple versions, pick most recent one | ||
$WingetCmd = $WingetInfo[-1].FileName | ||
$WingetCmd = $WingetInfo.FileName; | ||
} | ||
catch { | ||
#Get User context Winget Location | ||
if (Test-Path "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe") { | ||
$WingetCmd = "$env:LocalAppData\Microsoft\WindowsApps\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\winget.exe" | ||
if (Test-Path -Path $pu -PathType Leaf) { | ||
$WingetCmd = $pu; | ||
} | ||
} | ||
|
||
return $WingetCmd | ||
|
||
return $WingetCmd; | ||
} |
Oops, something went wrong.