Answer the question
In order to leave comments, you need to log in
Menu in powershell and case function?
Hello!
There is a menu, by pressing (selecting) an item, a part of the script is launched. How can I insert items from the case function into the menu?
Or can you advise how to implement it differently?
The script itself:
$Menu = Read-Host -Prompt "Meenu:
1. Computername
2. Install Net.Framework 3.5
3. Add to domain
4"
if($Menu -match "1"){
$ComputerName = Read-Host -Prompt "Give new computername:"
Rename-Computer -ComputerName $ComputerName
}elseif($Menu -match "2"){
Start-Process "C:\temp\Net_Framework_3_5" -ArgumentList "/s" -Wait
}
case($Menu -match "3"){
[Add-Computer -DomainName test.corp -co]
Answer the question
In order to leave comments, you need to log in
$FR = Read-Host "Ваш текст?`n1) Пункт 1`n2) Пункт 2`n3) Пункт 3`n4) Пункт 4`n5) Пункт 5`n"
switch ( $FR )
{
1
{
Write-Host "Выбран пункт 1"
...
}
2
{
Write-Host "Выбран пункт 2"
...
}
3
{
Write-Host "Выбран пункт 3"
...
}
4
{
Write-Host "Выбран пункт 4"
...
}
5
{
Write-Host "Выбран пункт 5"
...
}
default
{
Write-Host "Ошибка, выбран не существующий вариант." -ForegroundColor Red
Exit
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question