Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

PowerShell Out-String formatting

$
0
0

Hello,

Question:

I wrote that little script to remind me every month of Group policies I can delete.

Everything is workin, the only thing is I would like to have the Output (table) formatted in the mail. please see below.

Thank you.

$MyGPO          = ""
$MyGPOR         = ""
$Stars          = '*'*100
$Description    = "This GPO Report will display Group Policies with *Test* or *Remove -*  in the Displayname"
$a = `
    @{Expression={$_.Displayname};Label="Group Policy Name";width=100}, `
    @{Expression={$_.Description};Label="Group Policy Description";width=50}

$myGPOR = Get-GPO -all| where {$_.displayname -like "Remove -*"} | Format-Table $a

$MyGPOS1 = $MyGPOR | Out-String

$body = $stars + "`r`n" +`
        $description + "`r`n" +`
        $stars + "`r`n" +`
        $test  + "`r`n" +`
        $stars + "`r`n" +`
        " That report will be send every month as a reminder " + "`r`n" +`
        $stars`

#Send everything
 $email = @{
 From = "blabla"
 To = "blabla"
 Subject = "Group Policy Report for TEST GPO's"
 SMTPServer = "blabla"
 Body = $body
 }
send-mailmessage @email

THE EMAIL BODY LOOKS LIKE: I would like to have it formatted

****************************************************************************************************

This GPO Report will display Group Policies with *Test* or *Remove -* in the Displayname

****************************************************************************************************

Group Policy Name                                                                                   Group Policy Description                         

-----------------                                                                                   ------------------------                         

REMOVE - Group Policy Computer Settings                                                                        Can be remove/delete on 01-JUL-2013


Viewing all articles
Browse latest Browse all 21975

Trending Articles