locked
Powershell Issue RRS feed

  • Question

  • I have the following script I am testing and cannot get it to format correctly.

    When I run everything from the Sort lline up it works as it should with the grouping.

    When I run the entire script the html file created looks terrible and no legible information as below.

    Can anyone help.

    $a = "<style>"
    $a = $a + "BODY{background-color:peachpuff;}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
    $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
    $a = $a + "</style>"
    
    
    
    Get-ADComputer -Filter * -Properties * | 
    select Name,OperatingSystem,OperatingSystemServicePack | 
    Sort-Object Name | Format-Table Name,OperatingSystem -GroupBy OperatingSystem -AutoSize |
    ConvertTo-Html |
    out-file C:\scripts\test.html

    THIS IS THE FILL RUN HTML SAMPLE

    ClassId2e4f51ef21dd47e99d3c952918aff9cd pageHeaderEntry pageFooterEntry autosizeInfo shapeInfo groupingEntry
    033ecb2bc07a4d43b5ef94ed5a35d280 Microsoft.PowerShell.Commands.Internal.Format.AutosizeInfo Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo
    9e210fe47d09416682b841769c78b8a3 Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c
    4ec4f0187cb04f4cb6973460dfe252df
    9e210fe47d09416682b841769c78b8a3 Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry
    27c87ef9bbda4f709f6b4002fa4af63c
    4ec4f0187cb04f4cb6973460dfe252df
    9e210fe47d09416682b841769c78b8a3 Microsoft.PowerShell.Commands.Internal.Format.GroupingEntry
    27c87ef9bbda4f709f6b4002fa4af63c
    27c87ef9bbda4f709f6b4002fa4af63c

    Wednesday, March 19, 2014 4:50 PM

Answers

  • Yes - try doing it in PowerShell.  It is easier.

    $style=@'
    <style>
        body{
            background-color:peachpuff;
        }
        table{
            border-width: 1px;
            border-style: solid;
            border-color: black;
            border-collapse: collapse;
        }
        th{
            border-width: 1px;  
            padding: 0px;
            border-style: solid;
            border-color: black;
        }
        td{
            border-width: 1px;
            padding: 0px;
            border-style: solid;
            border-color: black;
        }
    </style>
    '@
    
    Get-ADComputer -Filter * -Properties * | 
    select Name,OperatingSystem,OperatingSystemServicePack |
    ConvertTo-Html -Head $style |
    Out-File Report.htm
    .\report.htm
     


    ¯\_(ツ)_/¯

    • Marked as answer by rlawrimore Wednesday, March 19, 2014 10:57 PM
    Wednesday, March 19, 2014 10:15 PM

All replies

  • Yes - try doing it in PowerShell.  It is easier.

    $style=@'
    <style>
        body{
            background-color:peachpuff;
        }
        table{
            border-width: 1px;
            border-style: solid;
            border-color: black;
            border-collapse: collapse;
        }
        th{
            border-width: 1px;  
            padding: 0px;
            border-style: solid;
            border-color: black;
        }
        td{
            border-width: 1px;
            padding: 0px;
            border-style: solid;
            border-color: black;
        }
    </style>
    '@
    
    Get-ADComputer -Filter * -Properties * | 
    select Name,OperatingSystem,OperatingSystemServicePack |
    ConvertTo-Html -Head $style |
    Out-File Report.htm
    .\report.htm
     


    ¯\_(ツ)_/¯

    • Marked as answer by rlawrimore Wednesday, March 19, 2014 10:57 PM
    Wednesday, March 19, 2014 10:15 PM
  • Perfect. I am just learning this stuff after all these years and it is pretty cool.
    Wednesday, March 19, 2014 10:58 PM