Code below collect user input and uses switch case statement to check if the input matches, and if it matches a function is called that will execute commands. Here’s the code: #get or read from user input $computer_name = read-host ( "Enter Computer Name:" ) switch ( $computer_name ) { #if the input is computer_1 then function func_comuputer1 is called computer_1 { func_computer1 } computer_2 { func_computer2 } } #function called if computer_1 is the input function func_computer1 { write-host "You entered Computer_1" #or replaced with other function like reboot / shutdown /or other commands #Restart-Computer -ComputerName computer_1 } #function called if computer_2 is the input function func_computer2 { write-host "You entered Computer_2" #or replaced with other function like reboot / shutdown /or other c...
Make the world a better place by sharing knowledge, ideas and anything that you can give that comes from the heart.