how to update individual keys and export them

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Ron Ron 2 months, 1 week ago.

  • Author
    Posts
  • #62068
    Profile photo of jacobo
    jacobo
    Participant

    Hallo everyone,

    I am wondering if someone can point me in the right direction here. I am not sure what approach to take.
    My intention is to generate a xml config file based on a hashtable.

    My issue is how to do an update of just one of the config keys without affecting the rest of the config.
    Is there a way i can do that with just one hashtable or perhpas if i need to split the config hashtable in smaller ones, not sure how i will do the merge properly. The final requirement is to have just one .xml config file.

    Thanks in advance for your replies.

    Jacobo

    
    $PVSConfigurationSourceServerSession = New-PSSession -ComputerName server1
    $Configuration = @{
        customer=@{
            ActiveDirectoryGC="server1:3268"; # GC stays for Global Catalog
        }
        script_info=@{
            ConfiguratioVersion="1.0.0";
            LastEditedby=$env:USERNAME
            LastEditedDate=(Get-Date)
        }
        microsoft_scvmm=@{
            Address="server2";
            TECAccounts="Test1","Test2";
        };
        microsoft_scvmm_hosts=@{
            HypervVersion="6.3.9600.17729";
        };
        citrix_pvs=@{
            Version = Invoke-Command -Session $PVSConfigurationSourceServerSession -ScriptBlock {Get-PvsVersion}
            Farm = Invoke-Command -Session $PVSConfigurationSourceServerSession -ScriptBlock {Get-PvsFarm}
            Sites =  Invoke-Command -Session $PVSConfigurationSourceServerSession -ScriptBlock {Get-PvsSite}
            
        };
        citrix_storefront=@{
            WebConfig = invoke-command -computername server2 {Get-Content C:\inetpub\wwwroot\web.config
        };
    
    
    }
    
    Export-Clixml -InputObject $Configuration -Path .\config\configuration.xml -Force
    
  • #62082
    Profile photo of Ron
    Ron
    Participant
    $Configuration = Import-Clixml -Path .\config\configuration.xml
    $Configuration.script_info.ConfiguratioVersion="1.1.0"
    $Configuration.script_info
    
    Name                           Value               
    ----                           -----               
    LastEditedDate                 1/18/2017 8:52:02 AM
    LastEditedby                   jacobo             
    ConfiguratioVersion            1.1.0               
    
    Export-Clixml -InputObject $Configuration -Path .\config\configuration.xml -Force

You must be logged in to reply to this topic.