El ejercicio me pide que lo use, pero no me lo han explicado.
Este es un fragmento del codigo
do{
$salirprocesos=0;
$proceso=0;
$gestionproceso=0;
write-host '---PROCESOS---'
write-host '¿Que desea hacer??'
write-host '1.Visualizar todos'
write-host '2.Visualizar uno'
write-host '3.Gestionar'
write-host '4.Salir'
#BUCLE PROCESOS MENU
do{
$opcionproceso1 = 0;
$opcionproceso1 = Read-Host 'Elige una opcion'
}while(($opcionproceso1 -ne 1)-and($opcionproceso1 -ne 2)-and($opcionproceso1 -ne 3)-and($opcionproceso1 -ne 4))
#PROCESOS ----> VISUALIZAR TODAS
if($opcionproceso1 -eq 1){
Get-Process
}
#PROCESOS ----> VISUALIZAR UNO
if($opcionproceso1 -eq 2){
$proceso = read-host 'Introduce el id del proceso que quieres visualizar'
Get-Process -id $proceso
}
#PROCESOS ----> GESTIONAR
if($opcionproceso1 -eq 3){
do{
write-host 'Iniciar'
write-host 'Parar'
write-host 'Pausar'
write-host '¿Que desea hacer con el proceso??'
$gestionproceso = read-host
if($gestionproceso -eq 'iniciar'){
$proceso = read-host 'Introduce el nombre del proceso que quieres iniciar'
START-PROCESS $proceso
Get-Process $proceso
write-host 'El proceso se ha iniciado'
}
if($gestionproceso -eq 'parar'){
$proceso = read-host 'Introduce el id del proceso que quieres parar'
STOP-PROCESS -id $proceso
Get-Process -id $proceso
write-host 'El proceso se ha detenido'
}
if($gestionproceso -eq 'pausar'){
$proceso = read-host 'Introduce el nombre del proceso que quieres pausar'
WAIT-PROCESS $proceso
Get-Process $proceso
write-host 'El proceso se ha pausado'
}
}while(($gestionproceso -ne 'parar')-and($gestionproceso -ne 'iniciar')-and($gestionproceso -ne 'pausar'))
}
#PROCESOS ----> SALIR
if($opcionproceso1 -eq 4){
$salirprocesos++
}
}while($salirprocesos -ne 1)
MOD: GeSHi
Sacado de Google:
Citar
The WhatIf switch runs a PowerShell script without actually running it. Rather than actually running the commands, the WhatIf switch only displays what the outcome of running the script would be if it were actually run.
Más info:
http://stackoverflow.com/questions/34749333/powershell-guidelines-for-confirm-force-and-whatif (http://stackoverflow.com/questions/34749333/powershell-guidelines-for-confirm-force-and-whatif)
https://blogs.msdn.microsoft.com/powershell/2007/02/25/supporting-whatif-confirm-verbose-in-scripts/ (https://blogs.msdn.microsoft.com/powershell/2007/02/25/supporting-whatif-confirm-verbose-in-scripts/)
https://blogs.technet.microsoft.com/heyscriptingguy/2011/11/21/make-a-simple-change-to-powershell-to-prevent-accidents/ (https://blogs.technet.microsoft.com/heyscriptingguy/2011/11/21/make-a-simple-change-to-powershell-to-prevent-accidents/)
Saludos!