Back in March I posted about a means to write down to web.config files
PowerShell (v2) - Adding AppSettings Elements to Web.config
After revisiting my post I realized it was pretty much wrong and completely useless. So, I set about to rewrite it with the help of a few folks on the forums.
How can I discard output of pipeline without using Out-Null?
Write-Output"The //configuration/appSettings element exists. Checking for children nodes."
# Gather //configuration/appSettings data
$appSettings=$xml.configuration[appSettings]
# Test to see if element has child nodes
if($appSettings.HasChildNodes)
{
# Output status to host
Write-Output"The appSettings elements has children. Checking arguments against existing values."
# Test to see if key exists.
if($appSetting= ($appSettings.ChildNodes | Where {$_.key -eq$key}))
{
# Output status to host
Write-Output"The element ($($key)) exists. Comparing values."
# Test to see if value matches
if($appSetting.value -eq$value)
{
# Value matches. Output status to host.
Write-Output"The key/value arguments are already set correctly."
}
else
{
# Value does not match. Attempt to update and output status to host.
&
About lamsim
Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.