none
Need help modifying a value in XML RRS feed

  • Question

  • Hi Scripting Guy,

        I am trying to figure out how to resolve a problem with an XML file used for configuring some software. Here is a snip of the XML:

    

    My goal is to read the Value of AutoLogin and if it is set to "True" the value needs to be changed to "False". I would also like to look at the Value of "ServerName" and if it isn't set to the correct server, it should update based on what it is set to.

    I started with the following code to detect but I cannot figure out how to modify and write the updated XML back:

    I appreciate any assistance you can provide.

    Making this change will help reduce excess Autodesk Vault license consumption by the add-ins associated with applications like AutoCAD.

    Tuesday, February 25, 2020 10:15 PM

All replies

  • Please do not post pictures of code or data.  Edit your post and fix or we cannot help you.

    Please read the following very carefully


    \_(ツ)_/

    Tuesday, February 25, 2020 10:26 PM
  • $xml.SelectSingleNode('//Property[@Name="AutoLogon"]',$nsmmgr)


    \_(ツ)_/

    Tuesday, February 25, 2020 10:29 PM
  • Sorry about that... here is the snip of the original XML:

    <?xml version="1.0"?>
    <Categories xmlns="http://schemas.autodesk.com/msd/plm/Preferences/2006-04-11">
      <Category ID="CopyDesignSettings">
        <Property Name="Use Old Copy Design" Value="False" />
      </Category>
      <Category ID="Login">
        <Property Name="AutoLogin" Value="False" />
        <Property Name="ServerName" Value="knoxvault-v20.mesainc.com" />
        <Property Name="UserName" Value="vaultcbolton" />
        <Property Name="SelectedAuthenticationType" Value="0" />
        <Property Name="Password" Value="m+FMtYXoDWY=" />
        <Property Name="DatabaseName" Value="PGGIF" />
        <Property Name="Expanded" Value="True" />
      </Category>

    and here is my current Powershell script that can read the property:

    [xml]$XML =  get-content "$env:UserProfile\AppData\Roaming\Autodesk\Autodesk Vault Professional 2019\ApplicationPreferences.xml"
    $results = $xml.Categories.Category.Property
    Foreach($result in $results){
        if($result.Name -Like 'AutoLogin'){
            If($Result.Value -eq 'False'){Write-host "AutoLogin is not currently enabled for Autodesk Vault Professional 2019 (Client)"}
            ELSE{Write-host "AutoLogin is currently enabled for Autodesk Vault Professional 2019 (Client)"
          }}
    }
    
    What I need to change is the ELSE line to modify the value to FALSE.

    Friday, March 6, 2020 9:17 PM
  • Ok.   Just change it.  Are you asking for someone to edit the file for you?  Just open it in notepad and change the value.

    If you want to do it in PowerShell just change that line to change the value. Why is that a problem?


    \_(ツ)_/

    Friday, March 6, 2020 11:10 PM