Error reading input file even with CDATA tags

Apr 26, 2011 at 6:46 PM
Edited Apr 27, 2011 at 3:12 AM

I am trying to do a test run of the scripts and I keep bombing out I get errors right away to start with the first one is

You cannot call a method on a null-valued expression.
At C:\SP2010\AutoSPInstaller\AutoSPInstallerMain.ps1:45 char:37
+ $xmlinput.Configuration.getAttribute <<<< ("Environment")
    + CategoryInfo          : InvalidOperation: (getAttribute:String) [], Runt
   imeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\SP2010\AutoSPInstaller\AutoSPInstallerMain.ps1:45 char:37
+ $xmlinput.Configuration.getAttribute <<<< ("Version")
    + CategoryInfo          : InvalidOperation: (getAttribute:String) [], Runt
   imeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

 

Then I get a dialog that says "Cannot find the specified config.xml file. C:\SP2010\AutoSPInstaller"

Not really sure why this is not working. I have tried running the script from PS both with an without appending the AutoSPInstallerInput.xml file to the string.

I am assuming it is not getting the input file but not sure why.

 

Edit ---

 

Ok I figured out partially why the above errors are happening. EVERY single account and password we have has a $ in it because thats how we specifiy service accounts. I enclosed these in CDATA tags but those tags are bombing when you try to read them in to the $xmlinput variable.

Example line it is failing on: <Account Username=<![CDATA[PACIFIC\$SP2010_Farm_Admin]]>

Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "'<' is an unexpected token. The expected token is '"' or '''. Line 16, position 27."

I was unclear on if "'s should be around the CDATA (but from an example I saw somewhere I assumed not) so I tried with quotes and instead got

Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "'<', hexadecimal value 0x3C, is an invalid attribute character. Line 16, position 28."

 

Still not sure how to fix this but at least I know what is failing...

Just to clarify this is the line in AutoSPInstallerMain script that is failing

[xml]$xmlinput = (Get-Content $InputFile) -replace ("localhost", $env:COMPUTERNAME)

I have manually tested this line trying to read in my AutoSPInstallerInput.xml and it fails. If i strip out the [xml] it actually reads the file in when I manually just put that line into powershell but if i leave it out in the script it fails even worse when I try to run the scripts.

Apr 27, 2011 at 3:45 PM

Any comment from the Author? This appears to be an issue with using passwords/usernames that use XML special characters but using the suggested CDATA tags to work around this is not working.

Coordinator
May 8, 2011 at 3:16 AM

I've since backtracked on the recommendation to use CDATA tags. Instead, I will just list in a comment at the top of the XML file the characters not to use in parameters (such as passwords). It was getting way too complicated to account for every scenario, then modify the script especially to pick up CDATA-tagged values etc.

The illegal characters that I know of are: (' " $ > < )

Brian