Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Menu
- {
- param
- (
- [Parameter(Mandatory = $true)]
- [string]
- $Title,
- [Parameter(Mandatory = $true)]
- [array]
- $Options
- )
- $MaxValue = $Options.Count - 1
- $Selection = 0
- $EnterPressed = $false
- Clear-Host
- while ($EnterPressed -eq $false)
- {
- Write-Host "$Title"
- for ($i = 0; $i -le $MaxValue; $i++)
- {
- if ($i -eq $Selection)
- {
- Write-Host "[ $($Options[$i]) ]" -BackgroundColor Cyan -ForegroundColor Black
- }
- else
- {
- Write-Host " $($Options[$i]) "
- }
- }
- $KeyInput = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown").VirtualKeyCode
- switch ($KeyInput)
- {
- "13"
- {
- # enter key
- $EnterPressed = $true
- return $Selection
- Clear-Host
- break
- }
- "38"
- {
- # down key
- if ($Selection -eq 0)
- {
- $Selection = $MaxValue
- }
- else
- {
- $Selection -= 1
- }
- Clear-Host
- break
- }
- "40"
- {
- # up key
- if ($Selection -eq $MaxValue)
- {
- $Selection = 0
- }
- else
- {
- $Selection +=1
- }
- Clear-Host
- break
- }
- Default
- {
- Clear-Host
- }
- }
- }
- }
- if ($RU)
- {
- $Title = "Выберите букву диска"
- }
- else
- {
- $Title = "Choose the drive letter"
- }
- $Options = (Get-Disk | Where-Object -FilterScript {$_.BusType -ne "USB"} | Get-Partition | Get-Volume | Where-Object -FilterScript {$null -ne $_.DriveLetter}).DriveLetter
- Menu -Title $Title -Options $Options
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement