Hi,
I have a JSON file with data to build various components. One of the components is for a LoadBalancer with multiple rules.
The cmdlets i need to use reference the different rules. How do isolate the values of each rule?
$JSONFile = ConvertFrom-Json "$(get-content ".\ConfigurationData.json")" $ConfigurationData = @{} $JSONFile | get-member -MemberType NoteProperty | Where-Object{ -not [string]::IsNullOrEmpty($JSONFile."$($_.name)")} | ForEach-Object {$ConfigurationData.add($_.name,$JSONFile."$($_.name)")}
Example of some of the JSON file:
"LoadBalancers": { "Name": "####-LB-DMZ-IN", "Description": "LoadBalancer for the Public DMZ in network tier", "Location": "London", "PublicIPName": "####-LB-DMZ-IN-PUBLICIP", "AllocationMethod": "Dynamic", "ResourceGroupName": "####-RSG-PUB-DMZ-IN", "FEConfigName": "####-LB-FRONTEND", "BEConfigName": "####-LB-BACKEND", "Rules": [{ "Name": "NATRule1", "RuleName": "####-DMZ-LB-NATRule-RDP", "Protocol": "TCP", "FEPort": "3389", "BEPort": "3389", "IdleTimeOut": "15" }, { "Name": "NatRule2", "RuleName":"####-DMZ-LB-NATRule-TCPIP", "Protocol": "TCP", "FEPort": "3391", "BEPort": "3392" }, { "Name": "Probe", "RuleName": "HEALTHCHECK-HTTP80", "Port": "80", "ProbeInterval": "15", "ProbeCount": "2" }, { "Name":"LBRule", "RuleName": "####-DMZ-LB-RULE", "Protocol": "TCP" }] }
So the cmdlet will be something like this:
New-LBRule -Name $ConfigurationData.Loadbalancer.Rules.Name.Probe.RuleName
Sorry if this is a bit confusing as hard to explain what i want to do. I know i could just build individual elements for each rule in the JSON file, but i want to be a bit clever with how i build out the JSON and use the POWER of PowerShell build at the logic.
Any help, suggestions of betters ways would be cool.
Thanks
TommyQ