Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Issue while editing appsettings.config file key and set the new value

$
0
0

Below is the code I am using and the error I am getting. Please advise and help.

Likewise I need to edit 2 more keys for timeout increase , please help on those ways of doing.

Code:

 

$ConfigFile = '<C:\Program Files\Apppath\bin\appSettings.config>'
## XML Node names and Attributes are CaSe SeNsItIvE!
$XPath = "root/config/add[@key='Command.DefaultTimeoutInSeconds']"
$Attribute = "30"
$NewValue = "180"

$xml = [xml](Get-Content -Path $ConfigFile)
$xml.SelectSingleNode($XPath).SetAttribute($Attribute,
$NewValue)
$xml.Save($ConfigFile)

Error:

You can not call a method with a null value expression.
 Occurrence line: 8 characters: 1

 + $xml.SelectSingleNode($XPath).SetAttribute($Attribute, $NewValue)

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) []、ARuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

 


Best Regards,SQLBoy






Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>