count array, create enough variables for number of array items as variables then knowingly call them

Posted on 2012-09-05
Medium Priority
Last Modified: 2012-10-22
am trying to create a function for tables. i figured the best way would be to put my column headers in an array, count the array, set a variable as 0 to use as a counter, and while the array count is greater than the counter, set a variable called "col1" or whatever the counter is. i can then setup datatable structures for the columns.
problem is, how do i then call them??
Question by:marexit
1 Comment
LVL 18

Accepted Solution

Learnctx earned 2000 total points
ID: 38370383
Well, I suppose you could do it like this.

$arrHeaders = "col1","col2","col3","col4"
foreach ($variable in $arrHeaders)
   New-Variable -Name $variable
   Get-Variable $variable

Open in new window


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question