powershell variable multiple output choice


shoober420

Active member
Member
Local time
7:34 AM
Posts
146
OS
Windows 11 27783
i tried googling how to do this, but the results think im asking something else. its hard to word what im trying to do in a search line. theres a string expression in this script that can output two monitors if they are both hooked up.

Code:
$DisplayPath = "EDID_{0}_{1}_{2}_{3}" -f $Manufacturer, $ProductID, $Model, $DisplayPathDigit

is there any way to allow a choice selection for a variable that can have multiple output?
 

My Computer

System One

  • OS
    Windows 11 27783
    Computer type
    PC/Desktop
    CPU
    Intel i7 7700 @4.0ghz
    Memory
    64gb DDR4
    Graphics Card(s)
    Radeon RX 5500 XT
    Other Info
    https://www.github.com/shoober420
There's basically nothing to go on here. How about some context?
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
Something like this;

Powershell:
$monitors = @(
    @{ Manufacturer = "24a"; ProductID = "35236dfg"; Model = "ModelADDFS"; DisplayPathDigit = "00" },
    @{ Manufacturer = "dsfg"; ProductID = "asdfas"; Model = "ModelSDF"; DisplayPathDigit = "01" }
)

$DisplayPaths = @()
foreach ($monitor in $monitors) {
    $DisplayPath = "EDID_{0}_{1}_{2}_{3}" -f $monitor.Manufacturer, $monitor.ProductID, $monitor.Model, $monitor.DisplayPathDigit
    $DisplayPaths += $DisplayPath
}
for ($i = 0; $i -lt $DisplayPaths.Count; $i++) {
    Write-Host "$($i + 1): $($DisplayPaths[$i])"
}
$choice = Read-Host "Please select a display by number"
if ($choice -as [int] -and $choice -gt 0 -and $choice -le $DisplayPaths.Count) {
    $selectedDisplayPath = $DisplayPaths[$choice - 1]
    Write-Host "You selected: $selectedDisplayPath"
} else {
    Write-Host "Invalid selection. Please run the program again and choose a valid number."
}

PS C:\Users\User\Desktop> .\test.ps1
1: EDID_24a_35236dfg_ModelADDFS_00
2: EDID_dsfg_asdfas_ModelSDF_01
Please select a display path by number:
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
Back
Top Bottom