winutil/functions/private/Test-WinUtilPackageManager.ps1
2023-10-04 10:08:10 -05:00

27 lines
666 B
PowerShell

function Test-WinUtilPackageManager {
<#
.DESCRIPTION
Checks for Winget or Choco depending on the parameter
#>
Param(
[System.Management.Automation.SwitchParameter]$winget,
[System.Management.Automation.SwitchParameter]$choco
)
if($winget){
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe) {
return $true
}
}
if($choco){
if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)){
return $true
}
}
return $false
}