Hi there I’m in the process of creating an interactive script to create virtual machines for my techs.
I would like to enumerate all network adapters and then assign a variable to each. I’m running into problems programmatically doing this, since the number of network adapters on each workstation might change. I’m not quite certain how to assign a variable dynamically based on the returned data. Eventually these variables will be loaded into an array witch will utilize the .NET method $host.ui.PromptForChoice()
$NicAdapters = Get-CimInstance -Class Win32_NetworkAdapter -Property NetConnectionID,NetConnectionStatus | Where-Object { $_.NetConnectionStatus -eq 2 } | Select-Object -Property NetConnectionID -ExpandProperty NetConnectionID
ForEach ($nic in $NicAdapters){
}