From 2cf129fa9c0d625ec82d232cb1a286e4e5604d02 Mon Sep 17 00:00:00 2001 From: Alex Kup <116945542+Lifailon@users.noreply.github.com> Date: Tue, 18 Apr 2023 15:22:54 +0300 Subject: [PATCH] Update README.md --- README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e4c5eb7..ed4efc5 100644 --- a/README.md +++ b/README.md @@ -1908,13 +1908,27 @@ set { Marshal.ThrowExceptionForHR(Vol().SetMute(value, System.Guid.Empty)); } ### HTML (HyperText Markup Language) `Get-Process | select Name, CPU | ConvertTo-HTML -As Table > "$home\desktop\proc-table.html"` вывод в формате List (Format-List) или Table (Format-Table) +`Import-Module PSWriteHTML` \ +`(Get-Module PSWriteHTML).ExportedCommands` \ +`Get-Service | Out-GridHtml -FilePath ~\Desktop\Get-Service-Out-GridHtml.html` +``` +Import-Module HtmlReport +$topVM = ps | Sort PrivateMemorySize -Descending | Select -First 10 | %{,@(($_.ProcessName + " " + $_.Id), $_.PrivateMemorySize)} +$topCPU = ps | Sort CPU -Descending | Select -First 10 | %{,@(($_.ProcessName + " " + $_.Id), $_.CPU)} +New-Report -Title "Piggy Processes" -Input { +New-Chart Bar "Top VM Users" -input $topVm +New-Chart Column "Top CPU Overall" -input $topCPU +ps | Select ProcessName, Id, CPU, WorkingSet, *MemorySize | New-Table "All Processes" +} > ~\Desktop\Get-Process-HtmlReport.html +``` ### XML (Extensible Markup Language) `$xml = [xml](Get-Content ~\desktop\home.rdg)` прочитать содержимое xml-файла \ `$xml = New-Object System.Xml.XmlDocument` создать пустой xml объект \ `$file = Resolve-Path("~\desktop\home.rdg")` забрать путь к файлу \ `$xml.load($file)` открыть файл \ -`$xml | Select-Xml "//RDCMan/file/group/server/properties"` \ +`$xml | Select-Xml -XPath "//RDCMan/file/group/server/properties/name[text() = '192.168.3.100']"` XPath-запрос поиска \ +`$xml.SelectNodes("//RDCMan/file/group/server/properties/name[text() = '192.168.3.100']")` \ `$xml.RDCMan.file.group.server.properties` \ `$xml.RDCMan.file.group.server[1].properties` \ `$xml.RDCMan.file.group.server[1].properties.displayName = "plex-02"` изменить значение \ @@ -1935,7 +1949,9 @@ $Cred | Export-CliXml -Path $CredFile return } } - +``` +### XPath +``` $FilterXPath = '' $RDPAuths = Get-WinEvent -ComputerName $srv -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" -FilterXPath $FilterXPath [xml[]]$xml = $RDPAuths | Foreach {$_.ToXml()} @@ -1956,11 +1972,13 @@ log = level = 7; }; -$log = [xml]" +$log = [xml]" + 7 " -$log = '{ +$log = ' +{ "log": { "level": 7 }