From 838d364b085cccbd126d8955eb6776b4e8c19647 Mon Sep 17 00:00:00 2001 From: Alex Kup <116945542+Lifailon@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:10:20 +0300 Subject: [PATCH] Add openvpn, nat, route, wireguard, vpnclient, html Pre add zabbix, ansible, winrm config, bit convertor, openssh, hyper-v, pki, openssl, influx regex --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 598474d..032bdb7 100644 --- a/README.md +++ b/README.md @@ -3241,8 +3241,69 @@ 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 ``` Import-Module 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 ```