Advertisement
Eliel_Sec

PowerShell_Modelo Criar Menus

Aug 31st, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##modelo para criar menus com funções no powershell
  2.  
  3.  
  4. function menu{
  5.  
  6. Write-Host "=========ESCOLHA UMA OPÇÃO========="
  7. Write-Host "Aperte 1 para Listar o conteudo do diretorio"
  8. Write-Host "Aperte 2 para executar um ping para google.com"
  9. Write-Host "Aperte 3 para baixar um video da internet"
  10. Write-Host "Aperte 'q' para sair do script"
  11.  
  12. }
  13.  
  14. do {
  15. menu
  16. $escolha = Read-Host "Digite um numero: "
  17. switch($escolha){
  18.    
  19.     '1' {
  20.         cls
  21.         Get-ChildItem }
  22.  
  23.     '2' {
  24.         cls
  25.         ping -n 8 google.com }
  26.  
  27.     '3' {
  28.         cls
  29.         Invoke-WebRequest -Uri http://kingston-rp.org/mp3/psychobilly/The%20Grims%20-%20Ride%20To%20Solitude.mp3 -OutFile c:\users\eliel\Desktop\musica_script.mp3
  30.         }
  31.  
  32.  
  33.     'q' {
  34.         cls
  35.         return }
  36. }
  37.  
  38. pause
  39.  
  40. }
  41. until($escolha -eq 'q')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement