Skip to content

Commit 88d749c

Browse files
committed
Fix for OS Menu choice
1 parent b69a70a commit 88d749c

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

UserPolicyReport/User_MAM_Report_Get.ps1

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -881,28 +881,45 @@ $OSChoicesCount = "2"
881881
$menu.Add($i,($OSChoices[$i-1]))}
882882

883883
Write-Host
884-
[int]$ans = Read-Host 'Choose an OS (numerical value)'
884+
$ans = Read-Host 'Choose an OS (numerical value)'
885885

886-
if ($ans -ne 1 -or $ans -ne 2){
887-
888-
Write-host "Invalid value enterered..." -ForegroundColor Red
889-
Write-Host
890-
break
891-
892-
}
886+
if($ans -eq "" -or $ans -eq $null){
893887

894-
=======
895-
896-
$selection = $menu.Item($ans)
888+
Write-Host "OS choice can't be null, please specify a valid OS..." -ForegroundColor Red
897889
Write-Host
890+
break
891+
892+
}
893+
894+
elseif(($ans -match "^[\d\.]+$") -eq $true){
895+
896+
$selection = $menu.Item([int]$ans)
898897

899898
if($selection){
900899

901-
902-
$OS = $OSChoices | ? { $_ -eq "$Selection" }
903-
904-
}
900+
$OS = $OSChoices | ? { $_ -eq "$Selection" }
901+
902+
}
903+
904+
else {
905905

906+
Write-Host "OS choice selection invalid, please specify a valid OS..." -ForegroundColor Red
907+
Write-Host
908+
break
909+
910+
}
911+
912+
}
913+
914+
else {
915+
916+
Write-Host "OS choice not an integer, please specify a valid OS..." -ForegroundColor Red
917+
Write-Host
918+
break
919+
920+
}
921+
922+
Write-Host
906923

907924
#endregion
908925

0 commit comments

Comments
 (0)