none
display this in Ft -auto table RRS feed

  • Question

  • hi

    any idea how i can change this to display in full tablesize

    ft -auto

     
    $servers = get-content "c:\scripts\servers.txt"
     
    Foreach ($server in $servers)  {
     
    Get-WmiObject Win32_Volume -ComputerName $server| ForEach {
                New-Object PSObject -Property @{
                    Computername = $server
                    Name = $_.Name
                    Label = $_.Label
                    FreeSpace_GB = ([Math]::Round($_.FreeSpace /1GB,2))
                    TotalSize_GB = ([Math]::Round($_.Capacity /1GB,2))
                    UsedSpace_GB = ([Math]::Round($_.Capacity /1GB,2)) - ([Math]::Round($_.FreeSpace /1GB,2))
                    blocksize = $_.blocksize
                    filesystem = $_.filesystem
                }
            }}

    Saturday, November 7, 2020 2:34 PM

All replies

  • Try this.

    $servers = get-content "c:\scripts\servers.txt"
    $data = @()
     
    Foreach ($server in $servers)  {
     
    Get-WmiObject Win32_Volume -ComputerName $server| ForEach {
             $data +=New-Object PSObject -Property @{
                    Computername = $server
                    Name = $_.Name
                    Label = $_.Label
                    FreeSpace_GB = ([Math]::Round($_.FreeSpace /1GB,2))
                    TotalSize_GB = ([Math]::Round($_.Capacity /1GB,2))
                    UsedSpace_GB = ([Math]::Round($_.Capacity /1GB,2)) - ([Math]::Round($_.FreeSpace /1GB,2))
                    blocksize = $_.blocksize
                    filesystem = $_.filesystem
                }
            }}
    
    $data | ft -AutoSize

    Regards
    Aayoosh Moitro


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This posting is provided "AS IS" with no warranties, and confers no rights.

    Saturday, November 7, 2020 5:03 PM
  • thanks

    how do i send the report in html format via email?

    Saturday, November 7, 2020 9:22 PM
  • trying this but its not working


    $css = @'
    <style>
    body { background-color:#E5E4E2;
    font-family:Monospace;
    font-size:10pt; }
    td, th { border:0px solid black;
    border-collapse:collapse;
    white-space:pre; }
    th { color:white;
    background-color:black; }
    table, tr, td, th { padding: 2px; margin: 0px ;white-space:pre; }
    tr:nth-child(odd) {background-color: lightgray}
    table { width:95%;margin-left:5px; margin-bottom:20px;}
    h2 {
    font-family:Tahoma;
    color:#6D7B8D;
    }

    .footer

    { color:green;
    margin-left:10px;
    font-family:Tahoma;
    font-size:8pt;
    font-style:italic;
    }

    </style>

    '@


     
    $servers = get-content "c:\scripts\servers.txt"
     
    $report = @()


    Foreach ($server in $servers)  {
     
    $report = Get-WmiObject Win32_Volume -ComputerName $server| ForEach {
                New-Object PSObject -Property @{
                    Computername = $server
                    Name = $_.Name
                    Label = $_.Label
                    FreeSpace_GB = ([Math]::Round($_.FreeSpace /1GB,2))
                    TotalSize_GB = ([Math]::Round($_.Capacity /1GB,2))
                    UsedSpace_GB = ([Math]::Round($_.Capacity /1GB,2)) - ([Math]::Round($_.FreeSpace /1GB,2))
                    Percent_Free = ([int]($_.Freespace*100/$_.Capacity))
    #                blocksize = $_.blocksize
                    filesystem = $_.filesystem
                }
            } | ft -auto Computername, Name, Label, Totalsize_GB, Freespace_GB, USedSpace_GB, Percent_Free }

    $reporthtml = $report | ConvertTo-Html -head $css


    $sMail = @{
    To = 'me@domain.com'
    From = 'you@domain.com'
    Subject = 'disk space reportt'
    BodyAsHtml = $true
    Body = $reporthtml | Out-String
    SmtpServer = 'smtp.domain.com'
    }

    Send-MailMessage @sMail


    • Edited by JonDoe321 Saturday, November 7, 2020 10:24 PM
    Saturday, November 7, 2020 10:24 PM
  • got it working but the convertto-html is not.

    any idea?

    $css = @'
    <style>
    body { background-color:#E5E4E2;
    font-family:Monospace;
    font-size:10pt; }
    td, th { border:0px solid black;
    border-collapse:collapse;
    white-space:pre; }
    th { color:white;
    background-color:black; }
    table, tr, td, th { padding: 2px; margin: 0px ;white-space:pre; }
    tr:nth-child(odd) {background-color: lightgray}
    table { width:95%;margin-left:5px; margin-bottom:20px;}
    h2 {
    font-family:Tahoma;
    color:#6D7B8D;
    }

    .footer

    { color:green;
    margin-left:10px;
    font-family:Tahoma;
    font-size:8pt;
    font-style:italic;
    }

    </style>

    '@


     
    $servers = get-content "c:\scripts\servers.txt"
     
    $report = @()


    Foreach ($server in $servers)  {
     
    $report = Get-WmiObject Win32_Volume -ComputerName $server| ForEach {
                New-Object PSObject -Property @{
                    Computername = $server
                    Name = $_.Name
                    Label = $_.Label
                    FreeSpace_GB = ([Math]::Round($_.FreeSpace /1GB,2))
                    TotalSize_GB = ([Math]::Round($_.Capacity /1GB,2))
                    UsedSpace_GB = ([Math]::Round($_.Capacity /1GB,2)) - ([Math]::Round($_.FreeSpace /1GB,2))
                    Percent_Free = ([int]($_.Freespace*100/$_.Capacity))
    #                blocksize = $_.blocksize
                    filesystem = $_.filesystem
                }
            } | ft -auto Computername, Name, Label, Totalsize_GB, Freespace_GB, USedSpace_GB, Percent_Free
     $reportname += $report       
            }
    #$report
    $reporthtml = $reportname | ConvertTo-Html -head $css


    $sMail = @{
    To = 'x@y.com'
    From = 'x@y.com'
    Subject = 'exchange disk space report'
    BodyAsHtml = $true
    Body = $reporthtml | Out-String
    SmtpServer = smtpserver'
    }

    Send-MailMessage @sMail

    Saturday, November 7, 2020 11:45 PM
  • Hi,

    The PowerShell forum has been migrated to the new Microsoft Q&A platform, I would suggest asking the experts over here:
    https://docs.microsoft.com/en-us/answers/topics/windows-server-powershell.html

    Best regards,
    Leon


    Blog: https://thesystemcenterblog.com LinkedIn:

    Sunday, November 8, 2020 8:46 AM
  • this is not working. Its only giving the last server on my list
    Sunday, November 8, 2020 6:21 PM