diff --git a/posh.txt b/posh.txt index e924434..8d7eaa3 100644 --- a/posh.txt +++ b/posh.txt @@ -3241,7 +3241,68 @@ bool: !!bool # boolean # HTML -Get-Process | select Name, CPU | ConvertTo-HTML -As Table > "$home\desktop\proc-table.html" # вывод в формате List (Format-List) или Table (Format-Table) +### ConvertFrom-Html + +function ConvertFrom-Html { + param ( + [Parameter(ValueFromPipeline)]$url + ) + $irm = Invoke-RestMethod $url + $HTMLFile = New-Object -ComObject HTMLFile + $Bytes = [System.Text.Encoding]::Unicode.GetBytes($irm) + $HTMLFile.write($Bytes) + ($HTMLFile.all | where {$_.tagname -eq "body"}).innerText +} + +$apache_status = "http://192.168.3.102/server-status" +$apache_status | ConvertFrom-Html + +### ConvertTo-Html + +Get-Process | select Name, CPU | ConvertTo-Html -As Table > "$home\desktop\proc-table.html" # вывод в формате List (Format-List) или Table (Format-Table) + +$servers = "ya.ru","ya.com","google.com" +$path = "$home\Desktop\Ping.html" +$header = @" + + + +Отчет о статусе серверов + +"@ +$body = @" +

Ping status

+

$(get-date -Format "dd.MM.yyyy hh:mm").

+"@ +$results = foreach ($server in $servers) { + if (Test-Connection $server -Count 1 -ea 0 -Quiet) { + $status = "Up" + } + else { + $status = "Down" + } + [PSCustomObject]@{ + Name = $server + Status = $status + } +} +$results | ConvertTo-Html -head $header -body $body | foreach { + $_ -replace "Down","Down" -replace "Up","Up" +} | Out-File $path +Invoke-Item $path ### PSWriteHTML @@ -4626,7 +4687,7 @@ $data = @{ } $token = (Invoke-RestMethod -Method POST -Uri $url -Body ($data | ConvertTo-Json) -ContentType "application/json").Result -$token = "914ee100f4e8c4b68a70eab2a0a1fb153cfcd4905421d0ffacb82c20a57aa50e" # создать токен в UI (http://192.168.3.102/zabbix/zabbix.php?action=token.list) +$token = "2eefd25fdf1590ebcdb7978b5bcea1fff755c65b255da8cbd723181b639bb789" # сгенерировать токен в UI (http://192.168.3.102/zabbix/zabbix.php?action=token.list) ### user.get