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 = @" + + +
+$(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 "