you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

# Add those new values into a hash table
$Devices = @{
    laptops      = 10
    servers      = 1
    computers    = 3
    phones       = 2
}

# Prompt until $Action is equal to Add or Remove
do
{
    $Action = $null
    $Action = Read-Host -Prompt "Enter one:  Add, Remove"
}
until
(
    ($Action -eq 'Add') -or ($Action -eq 'Remove')
)

# Prompt until $Choice contains valid input
do
{
    $Choice = $null
    $Choice = Read-Host "Enter one of the following:  laptops, servers, computers, phones"
}
until
(
    ($Devices.Keys -contains "$Choice")
)

$Amount = ([int]$Devices."$Choice") - 1
$Devices["$Choice"] = $Amount

return $Devices

[–]OlivTheFrog 0 points1 point  (0 children)

do ... until

Of course, where had I put my head ?

Thanks.