I am very very new to powershell
Working on doing some automated patching in our SQL server environments. I am first taking a DB backup and then applying patches and then sending output in an email
I need to figure out two things:
- How do I get only few columns displayed in the output? for example the backup-dbadatabase gives me about 20 columns which I don't need
- how do I get the results of second command in the email? when I run this script I only get the output of the first command in the email
$Results = backup-dbadatabase -sqlinstance abcsqlserver -database 'abc' -path \\abcsqlserver\Backup -type full -copyonly -compressbackup -ignorefilecheck;update-dbainstance abcsqlserver -KB 4019094 -path \\abcsqlserver\Patches -restart -confirm:$false
$to = 'email@example.com'
$smtp = 'mailrelay.abc.local'
$from = 'firstname.lastname@example.org'
$subject = 'SQL Server Patching on abcsqlserver'
$Body = $Results | convertto-html | Out-String
Send-MailMessage -To $to -From $from -Body $Body -bodyashtml -Subject $subject -SmtpServer $smtp
Any help is greatly appreciated