PowerShell script exchange
Post Reply
masber
Novice
Posts: 5
Liked: never
Joined: Jun 10, 2014 12:15 am
Full Name: masber
Contact:

get sender email address

Post by masber »

Hi very simple question,

How could I get the sender email address from the Veeam global options/settings using powershell?

thanks
tsightler
VP, Product Management
Posts: 6009
Liked: 2842 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: get sender email address

Post by tsightler »

I could be wrong, but I don't believe that any of the global server options are available via Powershell, however, you could probably get to that information directly from the SQL database. I believe that the "From Address" that you're looking for is stored in the "Options" table as an XML configuration, so something like this should work:

Code: Select all

$DBServer = "<SQL_Server>"  # Name of SQL Server hosting Veeam DB
$DBName = "VeeamBackup"  # Name of Veeam DB, default is VeeamBackup

# Setup SQL server connection
$SqlConn = New-Object System.Data.SqlClient.SqlConnection
$SqlConn.ConnectionString = "Server=$DBServer;Database=$DBName;Integrated Security=True"
$SqlConn.Open()
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.Connection = $SqlConn

# Grab XML options for job from SQL table, and get the From email address
$SqlCmd.CommandText = "select value from dbo.Options where name = 'email_notification'"
$MailFrom = ([xml]$SqlCmd.ExecuteScalar()).CMailOptions.From

# Close the SQL Connection
$SqlConn.Close()

# Write Mail From field to console
Write-Host $MailFrom
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests