Powershell report by mail?

Hi,

I'd like to send the output of a Powershell to myself by mail.

This is what I'm using:

$AppVpackages = Invoke-Command -ScriptBlock { Get-AppvClientPackage * -all } -ComputerName Myserver
$Body = $AppVpackages
$FromAddress = "mymailaddress"
$ToAddress = "mymailaddress"
$MessageSubject = "RDS Report"
$SendingServer = "mymailserver"
$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject,$body
$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
$SMTPClient.Send($SMTPMessage)

The $AppVPackages gives correct result:

PSComputerName       : mycomputer
RunspaceId           : e83788ec-0738-4ee3-bcfc-1f61043a9924
PackageId            : ae237bab-0844-450b-a075-aed1817c6498
VersionId            : 394fa10e-429e-43f1-9855-74a1da1a7fdf
Name                 : AppVPackage
...

But the output I receive in the mail is not ok:

Microsoft.AppV.AppvClientPowerShell.AppvClientPackage Microsoft.AppV.AppvClientPowerShell.AppvClientPackage Microsoft.AppV.AppvClientPowerShell.AppvClientPackage Microsoft.AppV.AppvClientPowerShell.AppvClientPackage Microsoft.AppV.AppvClientPowerShell.AppvClientPackage Microsoft.AppV.AppvClientPowerShell.AppvClientPackage Microsoft.AppV.AppvClientPowerShell.AppvClientPackage

What could be wrong with my script?

Note: I'd like to add several Powershell-scripts as a report, can I add them to $Body (f.e. $Body = $AppVPackages,$NumberOfUsers etc)?

Thanks for your input!

September 9th, 2015 5:27am

$AppVpackages = Invoke-Command -ScriptBlock { Get-AppvClientPackage * -all } -ComputerName Myserver |
   Format-List | Out-String

Free Windows Admin Tool Kit Click here and download it now
September 9th, 2015 5:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics