$c = Get-Content d:\your_file.txt
$c | Foreach-Object -Begin { $data = @{} } -Process { $a = $_ -split ':', 2; if ($a.Length -eq 2) { $data[$a[0].Trim()] = $a[1].Trim() } } -End { [PSCustomObject]$data }
$info = $c | ......
[float]($info.Download -replace 'Mbps.*')
PS D:\> $s = '<?xml version="1.0" encoding="utf-8"?>
>> <Data>
>> <Card>
>> <Id>123</Id>
>> <CreateDate>2022-06-20T21:01:32.7727011+05:00</CreateDate>
>> <CardData>
>> <Id>456</Id>
>> <Value>789</Value>
>> <Ord>0</Ord>
>> </CardData>
>> </Card>
>> </Data>'
PS D:\> $xml = [xml]$s
PS D:\> function ConvertFrom-Xml2 {
>> param([parameter(Mandatory, ValueFromPipeline)] [System.Xml.XmlNode] $node)
>> process {
>> if ($node.DocumentElement) { $node = $node.DocumentElement }
>> $oht = [ordered] @{}
>> $name = $node.Name
>> if ($node.FirstChild -is [system.xml.xmltext]) {
>> $oht.$name = $node.FirstChild.InnerText
>> } else {
>> $oht.$name = New-Object System.Collections.ArrayList
>> foreach ($child in $node.ChildNodes) {
>> $null = $oht.$name.Add((ConvertFrom-Xml2 $child))
>> }
>> }
>> $oht
>> }
>> }
PS D:\> $xml | ConvertFrom-Xml2 | ConvertTo-Json -Depth 10
{
"Data": [
{
"Card": [
{
"Id": "123"
},
{
"CreateDate": "2022-06-20T21:01:32.7727011+05:00"
},
{
"CardData": [
{
"Id": "456"
},
{
"Value": "789"
},
{
"Ord": "0"
}
]
}
]
}
]
}
$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
$env:PGRASSWORD = 'Pa$$w0rd'
$_.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]}
@echo off
set idx=1
set subfolder=1
for %%f in (*. mp4) do (
call :inc "%%f"
)
goto :EOF
:inc
echo %1 - %idx% - %subfolder%
set /a "idx+=1"
if .%idx% == .11 (
set /a "subfolder+=1"
set idx=1
)
$body = gci -force 'E:\BASE\enm*','F:\DATE\enm*' -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$_.fullname, '{0:N2} Gb' -f ($len / 1Gb)
}
$Body = $Body -join "`r`n"
Send-MailMessage -From 'test@test.ru' -To 'test@test.ru', -Subject "enm size" -Body $Body –SmtpServer '10.10.10.10'
gci -force 'E:\BASE\enm*','F:\DATE\enm*' -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$_.fullname, '{0:N2} Gb' -f ($len / 1Gb)
} | Tee-Object -Variable body
$Body = $Body -join "`r`n"
Send-MailMessage -From 'test@test.ru' -To 'test@test.ru', -Subject "enm size" -Body $Body –SmtpServer '10.10.10.10'
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