![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Array or Database or ?? Dear, I am confused about the different posibilities of storing information in powershell. I am not a programmer more of a consultant doing some sysadmin tasks from time to time in projects. right now I have created a script that will display a form with a dropdown box where i can select a certain "profile" let's say. My idea is that once the confirmation is hit I get the index number out of the listbox and retrieve my information from a pre-built datalist. However how should I construct such a data list containing multiple rows and multiple columns ? The results I am after is what you get after doing an import-csv. Basically you get an object which is indexed and has multiple properties. I've looked at creating my own custom object with multiple properties but I have no clue how to add data to it? I've been going at it for too long now and it's pretty late here in belgium so my mail might not make a lot of sense :-) Sincerely, Tonino Bruno Belgium |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Array or Database or ?? > I've looked at creating my own custom object with multiple properties but I > have no clue how to add data to it? I have an example here of creating your own object: http://marcoshaw.blogspot.com/2007/0...s-example.html I was mostly inspired by this post: http://thepowershellguy.com/blogs/po...baby-name.aspx Marco |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Array or Database or ?? I was doing something similar myself recently so I wrote a handy function for converting a collection of hashtables into objects: function Convert-HashToObject { $($args; $input) | foreach { $map = $_.psbase.keys | foreach { @{ name="$_" expression=$executioncontext.InvokeCommand.NewScriptBlock( "`$_.$_") } } $_ | select $map } } This funciton takes advantage of Select-Object's ability to create new psobjects from descriptions. Here's an example of how to use the function. First a collection of hash tables: PS (3) > @{a=1;b=2;c=3},@{a=11;b=22;c=33} Name Value ---- ----- a 1 b 2 c 3 a 11 b 22 c 33 and now convert that collection to PSObjects: PS (4) > @{a=1;b=2;c=3},@{a=11;b=22;c=33} | Convert-HashToObject a b c - - - 1 2 3 11 22 33 -bruce -- Bruce Payette [MSFT] Windows PowerShell Technical Lead Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scr.../hubs/msh.mspx My Book: http://manning.com/powershell "Marco Shaw" <marco.shaw@_NO_SPAM_gmail.com> wrote in message news:%23NaABaW1HHA.1344@TK2MSFTNGP04.phx.gbl... > >> I've looked at creating my own custom object with multiple properties but >> I have no clue how to add data to it? > > I have an example here of creating your own object: > http://marcoshaw.blogspot.com/2007/0...s-example.html > > I was mostly inspired by this post: > http://thepowershellguy.com/blogs/po...baby-name.aspx > > Marco |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Works database 2007 and Office database 2003 | maur scho | .NET General | 0 | 06-03-2008 01:48 AM |
| Compacting the database | Don | Live Mail | 17 | 03-10-2008 04:51 PM |
| database corruption | btblue | Live Mail | 7 | 03-09-2008 01:30 PM |
| how to assign values to array and how to create array via variable | Frank | PowerShell | 1 | 03-13-2007 05:18 PM |
| Jet database and Vista | jeffc | Vista General | 3 | 12-21-2006 09:51 AM |