Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - newb question - iteratate a hashtable

Reply
 
Old 05-18-2006   #1 (permalink)
Jeff Jarrell


 
 

newb question - iteratate a hashtable

Looks like I am one of the first here...

I have an associative array, created with
$xsize = @{}

I want to iterate the array, printing the results. I need to add a little
formatting to it.
"somestatictext KEY morestatictext VALUE

I assume it is somesort of foreach, but i don't know what to use for the
properties.

Any help?




My System SpecsSystem Spec
Old 05-19-2006   #2 (permalink)
Keith Hill [MVP]


 
 

Re: newb question - iteratate a hashtable

"Jeff Jarrell" <jjarrel_NOSPAM@yahoo.com> wrote in message
news:%23E$qp4ueGHA.4828@TK2MSFTNGP05.phx.gbl...
> Looks like I am one of the first here...
>
> I have an associative array, created with
> $xsize = @{}
>
> I want to iterate the array, printing the results. I need to add a little
> formatting to it.
> "somestatictext KEY morestatictext VALUE
>
> I assume it is somesort of foreach, but i don't know what to use for the
> properties.


Well you can use the built-in formatting:

PS> $xsize

....

or you can do this:

PS> foreach ($key in $xsize.keys) {$key}; foreach ($val in $xsize.values)
{$val}

--
Keith


My System SpecsSystem Spec
Old 05-19-2006   #3 (permalink)
applepwc


 
 

RE: newb question - iteratate a hashtable

PS 46> foreach ( $b in $x.keys ) { "the key is $b,the value is $($x.$b) `n" }
the key is foo,the value is bar


the key is apple,the value is me


PS 47> $x

Name Value
---- -----
foo bar
apple me


--
greeting

applepwc


"Jeff Jarrell" wrote:

> Looks like I am one of the first here...
>
> I have an associative array, created with
> $xsize = @{}
>
> I want to iterate the array, printing the results. I need to add a little
> formatting to it.
> "somestatictext KEY morestatictext VALUE
>
> I assume it is somesort of foreach, but i don't know what to use for the
> properties.
>
> Any help?
>
>
>
>

My System SpecsSystem Spec
Old 05-19-2006   #4 (permalink)
Jeff Jarrell


 
 

Re: newb question - iteratate a hashtable

now, thats what I am talking about. thanks.

jeff

"Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in
message news:OB2M2zveGHA.3484@TK2MSFTNGP02.phx.gbl...
> "Jeff Jarrell" <jjarrel_NOSPAM@yahoo.com> wrote in message
> news:%23E$qp4ueGHA.4828@TK2MSFTNGP05.phx.gbl...
>> Looks like I am one of the first here...
>>
>> I have an associative array, created with
>> $xsize = @{}
>>
>> I want to iterate the array, printing the results. I need to add a
>> little formatting to it.
>> "somestatictext KEY morestatictext VALUE
>>
>> I assume it is somesort of foreach, but i don't know what to use for the
>> properties.

>
> Well you can use the built-in formatting:
>
> PS> $xsize
>
> ...
>
> or you can do this:
>
> PS> foreach ($key in $xsize.keys) {$key}; foreach ($val in $xsize.values)
> {$val}
>
> --
> Keith
>
>



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Probably a complete newb question Network & Sharing
Help! IR NEWB Gaming
complete newb Network & Sharing
stoopid newb question PowerShell
NewB to Vista Mail has question Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46