2025-02-13 22:41:15 +00:00
|
|
|
|
# Assumes 64 bit system, registry keys may be different on 32 bit systems
|
|
|
|
|
|
Function Get-Apps($ComputerName, $CompStatus, $TableView) {
|
|
|
|
|
|
if ($CompStatus -eq "Online") {
|
|
|
|
|
|
Write-Progress -Activity "Getting apps for $ComputerName" -Status 'Querying local apps' -PercentComplete 30 -ParentId 1
|
2025-04-28 22:18:07 +00:00
|
|
|
|
$SHSAppsPath = Join-Path (get-item $PSScriptRoot).Parent.FullName 'Data\SHSApps.json'
|
|
|
|
|
|
$SHSApps = Get-Content $SHSAppsPath | ConvertFrom-Json
|
2025-02-13 22:41:15 +00:00
|
|
|
|
$sblock = {
|
2025-02-13 22:48:36 +00:00
|
|
|
|
$32RegPath = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
|
|
|
|
|
|
$64RegPath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
|
2025-02-13 22:41:15 +00:00
|
|
|
|
$apps = Get-ItemProperty $32RegPath |
|
|
|
|
|
|
Add-Member -NotePropertyName Computer -NotePropertyValue $env:ComputerName -PassThru |
|
|
|
|
|
|
Add-Member -NotePropertyName x86/x64 -NotePropertyValue 32 -PassThru
|
|
|
|
|
|
$apps += Get-ItemProperty $64RegPath |
|
2024-08-29 16:44:47 +00:00
|
|
|
|
Add-Member -NotePropertyName Computer -NotePropertyValue $env:ComputerName -PassThru |
|
2025-02-13 22:41:15 +00:00
|
|
|
|
Add-Member -NotePropertyName x86/x64 -NotePropertyValue 64 -PassThru
|
|
|
|
|
|
$apps += Get-Package |
|
|
|
|
|
|
Add-Member -NotePropertyName Computer -NotePropertyValue $env:ComputerName -PassThru
|
2025-04-28 22:18:07 +00:00
|
|
|
|
foreach ($app in ${using:SHSApps}) {
|
|
|
|
|
|
if (Test-Path $app.Path) {
|
|
|
|
|
|
$apps += [PSCustomObject]@{
|
2025-04-28 23:49:01 +00:00
|
|
|
|
DisplayName = $app.DisplayName
|
|
|
|
|
|
Computer = $env:ComputerName
|
2025-04-28 22:18:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-13 22:48:36 +00:00
|
|
|
|
$apps | Sort-Object 'x86/x64',DisplayName -Unique
|
2025-02-13 22:41:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
#Checks if local computer
|
|
|
|
|
|
if ($ComputerName -eq $env:COMPUTERNAME) {
|
2025-02-13 22:48:36 +00:00
|
|
|
|
$apps = Invoke-Command -ScriptBlock $sblock | ForEach-Object { $_.PSObject.TypeNames.Insert(0, 'GetPC.App'); $_ }
|
2025-02-13 22:41:15 +00:00
|
|
|
|
} else {
|
2025-02-13 22:48:36 +00:00
|
|
|
|
$apps = Invoke-Command -ComputerName $ComputerName -SessionOption $(New-PSSessionOption -MaxConnectionRetryCount 1 -NoMachineProfile) -ScriptBlock $sblock |
|
|
|
|
|
|
Select-Object -Property * -ExcludeProperty PSComputerName | ForEach-Object { $_.PSObject.TypeNames.Insert(0, 'GetPC.App'); $_ }
|
2024-06-11 18:27:55 +00:00
|
|
|
|
}
|
2024-07-08 21:10:21 +00:00
|
|
|
|
} else {
|
2025-02-13 22:41:15 +00:00
|
|
|
|
Write-Progress -Activity "Getting apps for $ComputerName" -Status 'Querying SCCM apps' -PercentComplete 10 -ParentId 1
|
|
|
|
|
|
$86apps, $64apps = Get-SCCM_Apps $ComputerName
|
|
|
|
|
|
$apps = ($86apps + $64apps) | Sort-Object 'x86/x64',DisplayName -Unique | ForEach-Object { $_.PSObject.TypeNames.Insert(0, 'GetPC.App'); $_ }
|
2024-06-11 18:27:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-13 22:41:15 +00:00
|
|
|
|
|
2024-06-11 18:27:55 +00:00
|
|
|
|
if ($TableView) {
|
|
|
|
|
|
$apps | Out-GridView -Title "Get-PC Apps - $ComputerName"
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
Write-Output $apps
|
|
|
|
|
|
}
|
2024-09-18 18:15:13 +00:00
|
|
|
|
Write-Progress -Activity "Getting apps for $ComputerName" -Completed
|
2024-06-11 18:27:55 +00:00
|
|
|
|
}
|