L'édition de fichier de configuration Web à l'aide de Microsoft PowerShell

je veux modifier mon fichier de configuration web à l'aide de powershell . je l'ai coincé quelque part . je veux mettre à jour appsettings et aussi connectionsstring informations en même temps quand je change dans powershel

J'ai ce code mais il change seulement apppsettings valeur quand je l'ai changer d'ici et de l'exécuter, mais je tiens également à inclure connectionstring ici. Comment puis-je l'atteindre ?

$webConfig = "C:\Inetpub\Wwwroot\application\web.config"
$doc = new-object System.Xml.XmlDocument
$doc.Load($webConfig)
$doc.get_DocumentElement()."appsetting".add[0].value = "true"
$doc.Save($webConfig)

Voici mon fichier de configuration web de

 <appSettings>
     <add key="mykey1" value="false"/>
     <add key="mykey2" value="true"/>
     <add key="mykey3" value="false"/>
</appSettings>

  <connectionstrings>

  <add name="myname1" connectinstring="Data Source=ABDULLAH-PC\SQLEXPRESS;Initial Catalog=UserDataBase;
  Integrated Security=True" providerName="System.Data.SqlClient" />
  <add name="myname2" connectinstring="myconnectionstring2" />
   <add name="myname3" connectinstring="myconnectionstring3" />
 </connectionStrings>

Ici, je veux mise à jour appsettings -( clé et de la valeur) et aussi connectionstrings( nom et initialcatalog)
dans le même temps

quand j'ai essayé votre code, il me donne cette erreur

Property '#text' cannot be found on this object; make sure it exists and is settable.
At line:3 char:66
+ $doc.SelectSingleNode('//appSettings/add[@key="mykey1"]/@value'). <<<< '#text' = 'false'
+ CategoryInfo          : InvalidOperation: (#text:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound

Property '#text' cannot be found on this object; make sure it exists and is settable.
At line:4 char:85
+ $doc.SelectSingleNode('//connectionStrings/add[@name="myname1"]/@connectionstring'). <<<< '#text'='my_string'       
  + CategoryInfo          : InvalidOperation: (#text:String) [], RuntimeException
   + FullyQualifiedErrorId : PropertyNotFound
InformationsquelleAutor user2375896 | 2013-07-27