Skip to content

Commit 94c0ba7

Browse files
author
William Lam
committed
Add -UniqueOnly switch to remove dupe process such as workloads w/K8s
1 parent 47113ad commit 94c0ba7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

powershell/VMApplicationInfo.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ Function Get-VMApplicationInfo {
1010
CSV or JSON output file
1111
.EXAMPLE
1212
Get-VMApplicationInfo -VM (Get-VM "DC-01")
13+
.EXAMPLE
14+
Get-VMApplicationInfo -VM (Get-VM "DC-01") -UniqueOnly
1315
.EXAMPLE
1416
Get-VMApplicationInfo -VM (Get-VM "DC-01") -Output CSV
1517
.EXAMPLE
1618
Get-VMApplicationInfo -VM (Get-VM "DC-01") -Output JSON
1719
#>
1820
param(
1921
[Parameter(Mandatory=$true)]$VM,
20-
[Parameter(Mandatory=$false)][ValidateSet("CSV","JSON")][String]$Output
22+
[Parameter(Mandatory=$false)][ValidateSet("CSV","JSON")][String]$Output,
23+
[Parameter(Mandatory=$false)][Switch]$UniqueOnly
2124
)
2225

2326
$appInfoValue = (Get-AdvancedSetting -Entity $VM -Name "guestinfo.appInfo").Value
@@ -28,7 +31,11 @@ Function Get-VMApplicationInfo {
2831
$appInfo = $appInfoValue | ConvertFrom-Json
2932
$appUpdateVersion = $appInfo.updateCounter
3033

31-
$results = $appInfo.applications | Sort-Object -Property a | FT @{Name="Application";e={$_.a}},@{Name="Version";e={$_.v}}
34+
if($UniqueOnly) {
35+
$results = $appInfo.applications | Sort-Object -Property a -Unique| FT @{Name="Application";e={$_.a}},@{Name="Version";e={$_.v}}
36+
} else {
37+
$results = $appInfo.applications | Sort-Object -Property a | FT @{Name="Application";e={$_.a}},@{Name="Version";e={$_.v}}
38+
}
3239

3340
Write-host -ForegroundColor Green "Application Discovery Time: $($appInfo.publishTime)"
3441
if($Output -eq "CSV") {

0 commit comments

Comments
 (0)