Prevents adding duplicate application names

Adds a validation check to ensure application names are unique.

If a user attempts to add an application with a name that already exists, a warning message is displayed, and the operation is cancelled.
This commit is contained in:
rbalsleyMSFT
2025-07-17 18:28:09 -07:00
parent da299d8a03
commit e639cee4ee
@@ -57,6 +57,12 @@ function Add-BYOApplication {
return
}
$listView = $State.Controls.lstApplications
# Check for duplicate names
$existingApp = $listView.Items | Where-Object { $_.Name -eq $name }
if ($existingApp) {
[System.Windows.MessageBox]::Show("An application with the name '$name' already exists.", "Duplicate Name", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
return
}
$priority = 1
if ($listView.Items.Count -gt 0) {
$priority = ($listView.Items | Measure-Object -Property Priority -Maximum).Maximum + 1