Author Posts

January 17, 2017 at 11:53 pm

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

January 18, 2017 at 1:58 pm

$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