-
Notifications
You must be signed in to change notification settings - Fork 2
/
10_15_2019-notifications-double_cmlet-loads.ps1
112 lines (85 loc) · 4.08 KB
/
10_15_2019-notifications-double_cmlet-loads.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Saber el tiempo que lleva alguien en Facebook
Get-Process | Select-Object name,Id,TotalProcessorTime
Get-WmiObject win32_process | select commandline | Format-Custom
$Proceso=Get-Process -Name notepad
$NombreF=(($Proceso).name)+'.dmp'
$Fichero = New-Object IO.FileStream($NombreF,[IO.FileMode]::Create)
(([PSObject].Assembly.GetType('System.Management.Automation.WindowsErrorReporting')).GetNestedType('NativeMethods', 'NonPublic')).GetMethod('MiniDumpWriteDump',[Reflection.BindingFlags] 'NonPublic, Static').Invoke($null, @($Proceso.Handle,$Proceso.Id,$Fichero.SafeFileHandle,[UInt32] 2,[IntPtr]::Zero,[IntPtr]::Zero,[IntPtr]::Zero))
$Fichero.Close()
############################################
# Utilizar dos cmdlets a la vez para conocer qué proceso padre crea a otro proceso hijo
Get-WmiObject win32_process | Select-Object name,ParentProcessId,ProcessId
Get-WmiObject win32_process | %{
"Al proceso " + $_.name + " le ejecuta el proceso " + (Get-Process -id $_.ParentProcessId).Name
}
#############################################
# Mostrar un mensaje emergente cuando la carga del procesador supera 10
## Carga del procesador
Get-WmiObject Win32_Processor | select LoadPercentage
## Crear un mensaje emergente
[System.Windows.MessageBox]::Show('Hash encontrado','Warning')
$balloon = New-Object System.Windows.Forms.NotifyIcon
#Configurar notificación
#Icono
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -Name notepad).Path)
$balloon.BalloonTipIcon = [string]$Icon = 'Info'
#Mensaje
$balloon.BalloonTipText = "Mensaje"
#Título
$balloon.BalloonTipTitle = "Hash encontrado"+$modulo.FileName
$balloon.Visible = $true
$balloon.ShowBalloonTip(5000)
# Crear el código que muestra mensaje si supera el consumo
$carga = Get-WmiObject Win32_Processor | select LoadPercentage
if($carga.LoadPercentage -gt 5)
{
[System.Windows.MessageBox]::Show('Carga en exceso','Warning')
$balloon = New-Object System.Windows.Forms.NotifyIcon
#Configurar notificación
#Icono
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -Name notepad).Path)
$balloon.BalloonTipIcon = [string]$Icon = 'Info'
#Mensaje
$balloon.BalloonTipText = "Mensaje"
#Título
$balloon.BalloonTipTitle = "Carga en exceso"+$carga.LoadPercentage
$balloon.Visible = $true
$balloon.ShowBalloonTip(5000)
}
#############################################
#Ejecutar PowerShell como administrador
while(1)
{
Get-Event | Remove-Event -ErrorAction SilentlyContinue
#Registrar el evento de ejecutar notepad
Register-WmiEvent -Query "SELECT * FROM Win32_ProcessStartTrace WHERE ProcessName='notepad.exe'"
Wait-Event -OutVariable Event | Out-Null
$Event.sourceargs.newevent | select-Object ProcessName,TIME_CREATED
}
#############################################
# REGISTRAR UN EVENTO Y MOSTRAR UN MENSAJE EMERGENTE EN POWERSHELL CUANDO SE EJECUTA UN PROGRAMA
## REGISTRAR UN EVENTO Y MOSTRAR UN MENSAJE EN POWERSHELL CUANDO SE EJECUTA UN PROGRAMA
while(1)
{
Get-Event | Remove-Event -ErrorAction SilentlyContinue
#Registrar el evento de ejecutar notepad
Register-WmiEvent -Query "SELECT * FROM Win32_ProcessStartTrace WHERE ProcessName='notepad.exe'"
Wait-Event -OutVariable Event | Out-Null
$Event.sourceargs.newevent | select-Object ProcessName,TIME_CREATED
}
## Crear un mensaje emergente
[System.Windows.MessageBox]::Show('Hash encontrado','Warning')
$balloon = New-Object System.Windows.Forms.NotifyIcon
#Configurar notificación
#Icono
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -Name notepad).Path)
$balloon.BalloonTipIcon = [string]$Icon = 'Info'
#Mensaje
$balloon.BalloonTipText = "Mensaje"
#Título
$balloon.BalloonTipTitle = "Hash encontrado"+$modulo.FileName
$balloon.Visible = $true
$balloon.ShowBalloonTip(5000)
#############################################
https://www.jesusninoc.com/06/25/utilizar-zonas-de-memoria-compartida-en-linux-mediante-wsl-desde-powershell/
#############################################