How can I reference a variable in a variable?

by Dec 20, 2010

My subject is probably not worded correctly. 

 

I am working on some scripts and using the "Send-MailMessage" command. I need to have some variables in the body of the message…. How can I do this? These variables are directories, log file locations, IP addresses, etc from the script. When the script finishes or fails I need to send an email with pertinent info about the job..

 

 

$bod = @"

Line 1 

Line 2 

$othervariable

Line 4

"@

 

Send-MailMessage -To user@user.com -Subject subject -From user@user.com -body $bod -SmtpServer server