$global:log = New-Object System.Collections.ArrayList
$testobj = New-Object -TypeName System.Diagnostics.EventLog
$testobj.Log = "Security"
Register-ObjectEvent -InputObject $testobj -EventName EntryWritten -Action {
param($sender, $e)
[void]$global:log.Add([PSCustomObject]@{Sender = $sender; Args = $e })
}
# Смотреть потом события в переменной
$global:log
$_.fullname, '{0:N2} Gb' -f ($len / 1Gb)}
$colors = @{$False='green'; $True='red'}
.........
$_.fullname, '<font color="{1}">{0:N2} Gb</font>' -f ($len / 1Gb), $colors[$len -le 2Gb]}
Get-Eventlog -logname Security -After Get-Date -Format "dd mm yyyy" -InstanceId 4624 | Format-List
Get-Eventlog -logname Security -After (Get-Date -Format "dd mm yyyy" ) -InstanceId 4624 | Format-List
Get-Eventlog -logname Security -After (Get-Date).Date -InstanceId 4624 | Format-List
Get-Eventlog -logname Security -After (Get-Date).Date -InstanceId 4624 | Where-Object { $_.ReplacementStrings[5] -match 'pupkin' -and $_.TimeGenerated -lt '2022-05-05 11:00'}
Get-Eventlog -logname Security -After (Get-Date).Date -InstanceId 4624 | Group-Object { $_.ReplacementStrings[5] }
Get-Eventlog -logname Security -After (Get-Date).Date -InstanceId 4624 | Select-Object @{n='Username'; e={$_.ReplacementStrings[5]}}, TimeGenerated
$but_imei.Add_Click(
{
IMEI
dateusers
$phone = $itembox.SelectedItem
write-host = $phone
}
)
add-type -AssemblyName System.Windows.Forms
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(500,400)
$Form.StartPosition = "CenterParent"
$itembox = New-Object System.Windows.Forms.ComboBox
$itembox.AutoSize = 1
$itembox.Location = New-Object System.Drawing.Point(40,40)
$itembox.DataSource = @("Samsung A12", "Redmi Note A6", "Другое:", "4")
$but_imei = New-Object System.Windows.Forms.Button
$but_imei.text = "Записать"
$but_imei.Location = "400,100"
$but_imei.AutoSize = 1
$but_imei.Add_Click(
{
write-host $itembox.SelectedItem -fore green
}
)
$Form.Controls.Add($itembox)
$Form.Controls.Add($but_imei)
$Form.ShowDialog()
$Date1=(Get-Date).Date
$Date2=(Get-Date).Date.AddDays(7)
$NextBirthdays = Get-ADUser -filter "Enabled -eq 'True'" -properties birthday -SearchBase 'DC=firma,DC=local' |
Select-Object birthday, Name |
Where-Object { $_.birthday -ge $Date1 -and $_.birthday -le $Date2 }
# Формируем текст письма
$messagetemplate = " {0}: {1}`r`n"
$message = ""
foreaach ($b in $NextBirthdays) {
$message += $messagetemplate -f $b.Name, $b.birthday
}
# Ну и тут их шлём кому попало
Send-MailMessage ....