July 31, 2014 at 8:07 am #17658
Hello, I am new to powershell just watched the jumpstart videos two days ago. Being a former Linux admin/dev I really like powershell and I am very excited to get involved with the community.
Here is the problem I am trying to solve. I am creating a script to promote a web page from DEV to UAT and then Production if all goes well. So the first thing I am really trying to do is change the web.config file to set debug = false/true depending on some logic I will define. Then I want to change the SQL DB connection string to point to the target environment. The debug value works great.
The problem I am having is with the connection string.
$webConfig = "C:\users\%user%\desktop\gsrs\web\web.config" $doc = new-object System.Xml.XmlDocument $doc.Load($webConfig) $doc.get_DocumentElement()."system.web".compilation.debug = "true" $doc.Save($webConfig) $doc.get_documentelement().configuration.connectionstring = "test"
The property 'connectionstring' cannot be found on this object. Verify that the property exists and can be set.
At line:6 char:1
+ $doc.get_documentelement().configuration.connectionstring = "test"
+ CategoryInfo : InvalidOperation: (:) , RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
I have tried with a configuration.connectionstring.add
and a few other variations.
I know this is something small and I am just missing it. Your help is greatly appreciated.
Thank you in advance.....
July 31, 2014 at 8:37 am #17659
I've often had more success in using an Xpath query to select a node, rather than trying to traverse the DOM tree. So, you'd query for the ConnectonString node, and then set it. I'm guessing now that whatever element you're referencing isn't the one you think you got.
July 31, 2014 at 9:00 am #17661
Thanks Don. I will read the documentation on that and give it a try.
July 31, 2014 at 1:09 pm #17673
I'm with Don on this one. Once you get the hang of Xpath it's a one-stop shop where you don't really have to use any other method.
I pulled this from one of my scripts to give you an idea on the syntax
August 1, 2014 at 6:57 am #17695
Thank you both. I was able to get this running last night. unfortunately I was unable to post because my companies web filter blocked this site due to spam issues. I was able to work with the infrastructure team to get this site added back to the approved list.
August 1, 2014 at 6:59 am #17696
I'd be interested in knowing what the spam issues were, if you're able to share. Apart from opt-in notifications from these forums, the site doesn't send any email.
August 1, 2014 at 7:13 am #17697
When I asked the infrastructure guys about it they said it was just how scansafe categorized powershell.org. I was able to get to it in the morning when I first asked this question. Then by that afternoon it was blocked. I had the admin fix it but still not sure on why cisco connect anywhere scansafe blocked it. I wish I could be more help.
You must be logged in to reply to this topic.