This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RAUL UNZUE - ELBLOGDENEGU | |
# https://www.maquinasvirtuales.eu/powershell-script-para-matar-procesos-windows-enlazados/ | |
# Revisar si existen en el sistema dos procesos java.exe y acslaunch_win-32 | |
# SABER EL USUARIO | |
$usuario=C:\windows\system32\whoami.exe | |
# ELIMINAR DOMINIO | |
$usuariomodificado=$usuario.Substring(5) | |
# EXTRAER USUARIO, SESION ID Y PROCESOS ASOCIADOS AL USUARIO | |
Get-Process -IncludeUserName | Select-Object Username,SessionID | Where-Object { $_.UserName -ne $null -and $_.UserName.Equals("NEGU\$usuariomodificado") } | |
Get-Process -IncludeUserName | Select-Object UserName,SessionId,ProcessName | Where-Object { $_.UserName -ne $null -and $_.UserName.Equals("NEGU\$usuariomodificado") } | Set-Content C:\Users\$usuariomodificado\Desktop\proceso1.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script Raúl Unzué - El Blog de Negu | |
# Buscamos modificar un valor en una clave de registro | |
# relacionando directorio activo con otra base de datos | |
# SABER EL USUARIO | |
$usuario=C:\windows\system32\whoami.exe | |
# ELIMINAR DOMINIO | |
$usuariomodificado=$usuario.Substring(5) | |
# SABER SID DE LISTADO | |
# BUSCAMOS USUARIO EN DA | |
(Get-Content "\\SYNOLOGY\SCRIPTS\usuarios-active-directory.txt") | Select-String -Pattern $usuariomodificado | Set-Content "\\SYNOLOGY\SCRIPTS\sid-$usuariomodificado.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cargamos modulo | |
Add-PSSnapin Citrix.Broker.Admin.V2 | |
#Obtenemos las sesiones | |
$sesiones=Get-BrokerSession | Select-Object Username | Set-Content C:\Scripts\Usuario.txt | |
# Limpiamos los espacios en blanco | |
(gc C:\Scripts\Usuario.txt) | ? {$_.trim() -ne "" } | Set-Content C:\Scripts\Usuario.txt | |
(gc C:\Scripts\Usuario.txt) -replace ("@{UserName=", "") -replace ("}", "") | Set-Content C:\Scripts\Usuario.txt | |
(gc C:\Scripts\Usuario.txt) | ? {$_.trim() -ne "" } | Set-Content C:\Scripts\Usuario.txt | |
$Existe=(gc C:\Scripts\Usuario.txt) | |
#Cerramos todas las sesiones de los usuarios detectadas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cargamos modulo | |
Add-PSSnapin Citrix.Broker.Admin.V2 | |
# Obtenemos las sesiones | |
(Get-BrokerSession | Select-Object -Property BrokeringUserName | Format-Wide -Column 1 | Out-String) | Set-Content C:\Scripts\Usuario.txt | |
# Limpiamos los espacios en blanco | |
(gc C:\Scripts\Usuarios.txt) | ? {$_.trim() -ne "" } | Set-Content C:\Scripts\Usuarios.txt | |
$Existe=C:\Scripts\Usuarios.txt | |
#Cerramos todas las sesiones de los usuarios detectadas | |
If ($Existe -eq $True) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################### | |
######### RAUL UNZUE - ELBLOGDENEGU ####### | |
########################################### | |
#Script limpiar users para Citrix FSLOGIX # | |
########################################### | |
# EMPEZAMOS LOG: | |
Start-Transcript ("c:\scripts\logs\OWNER-ScriptLog{0:yyyyMMdd-HHmm}.txt" -f (Get-Date)) | |
# CARPETA PERFILES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuramos Variables | |
$Total = 0 | |
$Usadas = 0 | |
$PorcentajeUso = 0 | |
$ReturnString = 0 | |
$ReturnValor = 0 | |
# Obtendremos los datos mediante WMI | |
$licensePool = gwmi -class "Citrix_GT_License_Pool" -Namespace "ROOT\CitrixLicensing" -comp SRVLICENCIAS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$emailSmtpServer = "smtp.elblogdenegu.com" | |
$emailSmtpServerPort = "587" | |
$emailSmtpUser = "maquinasvirtuales@elblogdenegu.com" | |
$emailSmtpPass = "xxxxxx" | |
$emailFrom = "maquinasvirtuales@elblogdenegu.com" | |
$emailTo = "prueba01@maquinasvirtuales.eu" | |
$emailcc="prueba02@maquinasvirtuales.eu" | |
$emailMessage = New-Object System.Net.Mail.MailMessage($emailFrom , $emailTo ) | |
$emailMessage.cc.add($emailcc) | |
$emailMessage.Subject = "TEST" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################### | |
# SCRIPT EL BLOG DE NEGU - RAUL UNZUE | |
##################################### | |
# Pasamos la ruta a nuestro PATH | |
$env:Path = $env:Path + ';C:\Program Files (x86)\Citrix\Licensing\LS\' | |
# Obtener licencias | |
$FilePath = "C:\Scripts\Citrix_Licence_Used.txt" | |
#$Exe = "C:\Program Files (x86)\Citrix\Licensing\LS" | |
#cd $Exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script Raul Unzue - El Blog de Negu | |
# Revisa que al usuario le faltan menos de 7 días para caducar licencia outlook | |
# Le manda un correo para que introduzca sus datos para activarla nuevamente | |
#################### | |
# SABER EL USUARIO | |
#################### | |
$usuario=C:\windows\system32\whoami.exe | |
#################### | |
# ELIMINAR DOMINIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################### | |
# FUNCION SABER LINEA | |
###################### | |
function linea | |
{ | |
$input | Select-String '.' | Select-Object -Property LineNumber, Line | |
} | |
############################### | |
# LISTAR DISCOS Y TAMAÑOS VHDX | |
############################### |