Mảng PowerShell sang HTML
Có lẽ bạn sẽ gặp may mắn hơn nếu bạn tạo một đối tượng tùy chỉnh và chuyển đổi nó thành HTML thay thế $Header = @" "@ $Data = New-Object -TypeName psobject -Property @{ List = $list.Title Workflow = $workflowSubscription.Name ListID = $listItem['ID'] WorkflowStatus = $workflowInstance.Status LastUpdated = $workflowInstance.LastUpdated } $Data | Select-Object -Property List, Workflow, ListID, WorkflowStatus, LastUpdated | ConvertTo-Html -Head $Header | Out-File -FilePath C:\Report.html Bài đăng này có hữu ích không? Tạo một trang HTML từ một hoặc nhiều đối tượng PowerShell Syntax ConvertTo-Html [[-head] string[] ] [[-title] string] [[-body] string[] ] [-CssUri Uri] [[-property] Object[] ] [-As {TABLE | LIST}] [-inputObject psobject] [-PreContent string[]] [-PostContent string[]] [CommonParameters] ConvertTo-Html [-Fragment] [[-property] Object[] ] [-As {TABLE | LIST}] [-inputObject psobject] [-PreContent string[]] [-PostContent string[]] [CommonParameters] Key -As string The object property names appear as HTML table column headings. Display the date as HTML on the console : PS C:\> get-date | convertto-html Save the system processes to C:\processes.html PS C:\> Get-Process | ConvertTo-Html name,path,fileversion | Set-Content c:\processes.htm Save the system services to C:\services.html PS C:\> get-service | ConvertTo-Html -Title "Services" -Body " The result of get-service" -Property Name,Status > c:\services.htmlSave the system services to C:\services.html and format in color (example from Hung Yuwu ): PS C:\> get-service | ConvertTo-Html -Title "Services" -Body " The result of get-service" -Property Name,Status |foreach {if($_ -like "* Running | *"){$_ -replace "Stopped | *"){$_ -replace "Save the system services to C:\services.html and format with css, then open the HTML page with Invoke-Item: PS C:\> get-service | ConvertTo-Html -CssUri "SS64.css" > c:\services.html Get events from the "Windows PowerShell" event log, select only the ID, Level, and Task properties and format as HTML: PS C:\> get-eventlog -log "Windows PowerShell" | convertto-html -property id, level, task “If you have an important point to make, don’t try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack” ~ Winston Churchill Related PowerShell Cmdlets: export-clixml - Produce a clixml representation of a PowerShell objects. Copyright © 1999-2023 SS64.com
Some rights reserved |