wingetautoupdate/Winget-AutoUpdate/functions/Get-WingetSystemApps.ps1

18 lines
741 B
PowerShell
Raw Normal View History

2023-09-15 14:38:54 +00:00
function Get-WingetSystemApps
{
# Json File, where to export system installed apps
$jsonFile = ('{0}\winget_system_apps.txt' -f $WorkingDir)
2023-09-15 14:38:54 +00:00
# Get list of installed Winget apps to json file
$null = (& $Winget export -o $jsonFile --accept-source-agreements -s winget)
2023-09-15 14:38:54 +00:00
# Convert json file to txt file with app ids
$InstalledApps = (Get-Content -Path $jsonFile | ConvertFrom-Json)
2023-09-15 14:38:54 +00:00
# Save app list
$null = (Set-Content -Value $InstalledApps.Sources.Packages.PackageIdentifier -Path $jsonFile -Force -Confirm:$False -ErrorAction SilentlyContinue)
2023-09-15 14:38:54 +00:00
# Sort app list
$null = (Get-Content -Path $jsonFile | Sort-Object | Set-Content -Path $jsonFile -Force -Confirm:$False -ErrorAction SilentlyContinue)
}