sirbounty
asked on
Why won't powershell believe me?
I'm running a script from visual studio.
My script calls a setup script, which also reads an xml file.
The xml file has a template message for the html body much like:
<FailedNotice>The process failed. The error code is {0}. Please see <a href=http://somewhere>online documentation</a> for instructions</FailedNotice >
In my setup script, I set a variable to this:
[string]$FailedNotice = [system.web.httputility]:: htmldecode ($settings .config.Te mplates.Fa iledNotice )
When my script concludes, if the proper exit code is found for a failure, it sends a message with the htmlbody:
[string]$body = $FailedNotice -f $errorCode
However, my body continues to be displayed in the email as an system.xml.xmlelement
To fix it, I apparently had to change it to
[string]$body = ($FailedNotice -f $errorCode).tostring()
But I want to know why?
My script calls a setup script, which also reads an xml file.
The xml file has a template message for the html body much like:
<FailedNotice>The process failed. The error code is {0}. Please see <a href=http://somewhere>online documentation</a> for instructions</FailedNotice
In my setup script, I set a variable to this:
[string]$FailedNotice = [system.web.httputility]::
When my script concludes, if the proper exit code is found for a failure, it sends a message with the htmlbody:
[string]$body = $FailedNotice -f $errorCode
However, my body continues to be displayed in the email as an system.xml.xmlelement
To fix it, I apparently had to change it to
[string]$body = ($FailedNotice -f $errorCode).tostring()
But I want to know why?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$FailedNotice = ([system.web.httputility]:
or possibly
$body = $FailedNotice.tostring() -f $errorCode
I'll give it a try. Thanks.