Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Powershell and ini files
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jacques Barathon [MS]  
View profile  
 More options Jul 20 2007, 6:30 pm
Newsgroups: microsoft.public.windows.powershell
From: "Jacques Barathon [MS]" <jbara...@online.microsoft.com>
Date: Sat, 21 Jul 2007 00:30:17 +0200
Local: Fri, Jul 20 2007 6:30 pm
Subject: Re: Powershell and ini files
"Selko" <Se...@discussions.microsoft.com> wrote in message

news:E8DF5254-C606-472D-A814-8225FE596758@microsoft.com...

> hy this works.... thanks
> but what if i got a shema like this:

> [exchangeserver]
> server1=aaaaa
> server2=bbbbb
> server3=cccccc
> [domaincontroller]
> server1=ddddd
> server2=eeeee
> server3=ffffffff

This should work, although not thoroughly tested:

--- import-ini.ps1 ---
param ($file)

$ini = @{}
switch -regex -file $file
{
  "^\[(.+)\]$"
  {
    $section = $matches[1]
    $ini[$section] = @{}
  }
  "(.+)=(.+)"
  {
    $name,$value = $matches[1..2]
    $ini[$section][$name] = $value
  }

}

$ini
--- import-ini ---

PS> $servers = import-ini servers.ini
PS> $servers["exchangeserver"]["server1"]
aaaaa
PS> $servers["domaincontroller"]["server1"]
ddddd

Hope that helps,
Jacques


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.