====== PowerShell ======
===== SSH =====
ssh @ -p
===== Desorden =====
Para activar Powershell en pc remota
Enable-PSRemoting
[[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enable-psremoting?view=powershell-7.2]]
# Ver servicios:
get-service
# guadar en una variable las credenciales:
$cred = get-Credential -credential admin@dom
#usar credencial y consultar servicios en otra máquina:
Get-WMIObject Win32_Service -computer MAQUINAREMOTA -credential $cred
# esto me dio error, pero si lo guardo en una variable funciona:
$service = Get-Service -ComputerName MAQUINAREMOTA
$service
# Reiniciar PC, no funciono:
Restart-Computer -ComputerName MAQUINAREMOTA
# Cargar a variable unos servicios
$service = Get-Service -ComputerName MAQUINAREMOTA -Name "*VNC*"
$service #para mostarlo en pantalla
#Ahora de ese VNC quiero ver sus metodos:
$service | Get-Member -Type Method
# me mostrará lo metoods que tinee ese servicio, iniciar, stop, ojo iniciar VNC requiere unos parametros.
$service.Stop() #Ojo cuidado que apaga el servicio pero para iniciarlo es dificil por los parametros
* [[https://learn-powershell.net/2012/01/15/startingstopping-and-restarting-remote-services-with-powershell/]]
* [[https://www.solvetic.com/topic/5427-como-detener-o-iniciar-servicio-en-powershell/]]
* [[https://phoenixnap.com/kb/how-to-restart-windows-server-2016]]
* [[https://stackoverflow.com/questions/344924/filter-services-when-calling-get-service]]
Comandos para reiniciar PC:
por CMD, el s lo apaga el /r lo reinicia (el shutdown -a aborta el reinicio o apagado)
shutdown /r /m \\[MI PC REMOTO] /t 60 /c “Por favor, finalice sus tareas”
* [[https://www.linio.com.pe/p/disco-solido-kingston-a400-480gb-rzfehi]]
Con PowerShell:
Restart-Computer –ComputerName “NAME_OF_SYSTEM”
* [[https://phoenixnap.com/kb/how-to-restart-windows-server-2016]]
* [[https://chcamp17.com/es/44-reboot-windows-from-powershell.html]]
Conexion remota:
* [[https://www.youtube.com/watch?v=RvRNKMnTXYg]]
* [[https://www.ipswitch.com/es/blog/usando-los-servicios-de-windows-en-powershell]]
* [[https://www.solvetic.com/topic/5427-como-detener-o-iniciar-servicio-en-powershell/]]
* [[https://sid-500.com/2017/08/28/powershell-using-restart-computer-to-restart-your-computer-and-remote-computers/]]
* [[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-pssession?view=powershell-7.2]]