So the easiest way to explain my problem is for me to show you this simplified version of what I'm trying to do:
PS C:\> $a = 'hello' PS C:\> $a hello PS C:\> $b = '$a world!' PS C:\> $b $a world!
Now what I really want is for the invokation of $b to return 'hello world!' but I apparently cannot call a variable within anther variable like this. Does anyone have any suggestions or work-arounds? I feel like I'm just missing something obvious here.
Edit: a more accurate version of what I'm trying to do:
PS C:\> $selHost = (get-content c:\scripts\hosts.txt) PS C:\> $selhost spr-it-minion PS C:\> $a = (get-content c:\scripts\config.txt) PS C:\> $a $selhost Is Offline! PS C:\> $b = "$a" PS C:\> $b $selhost Is Offline!
So I'm pulling the first line out of hosts.txt and setting it to $selhost which is just 'spr-it-minion'. I then pull the second line out of config.txt which is just the string '$selhost is offline!' in hopes that when I call $a I get 'spr-it-minion is offline!' and I'm not sure what to do.
Edit II: the contents of hosts.txt and config.txt respectively.
spr-it-minion spr-saflok spr-crosby spr-vmhost01 spr-vmhost02 spr-vmhost03
172.31.1.124 $selhost Is Offline! $selhost Is Offline! firstname.lastname@example.org email@example.com
Edit III: The Pastebin to my actual script if any of you are interested.
Line 15: I set $alertSubject to the string "$selhost is offline!" with no quotes or anything.
Line 82: I use $alertSubject as the subject line of an email alert hoping that that variable it contains will have it's value represented like: "spr-it-minion is offline!" but when I get the email or try to write-host $alertSubject anywhere in the script it just says "$selhost is offline!"