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