Solved

Powershell - Dynamically named DataTable

Posted on 2016-07-27
2
31 Views
Last Modified: 2016-07-27
Experts-

I use code similar to this to dynamically create variables:
New-Variable -Name "var$i" -Value $x
Get-Variable -Name "var$i" -ValueOnly

Open in new window


But I am not sure how to proceed creating dynamically named DataTables.

For example, I have a CSV with sets of domains on them.  For each domain, I want to create a dynamically named DataTable to store the data for that specific domain.  After doing a bit of processing I'll need to merge all the data tables into one procedurally.  Is there a way I can dynamically create these tables?
0
Comment
Question by:Dustin Saunders
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 41731387
Instead of using dynamically named variables, why not use a hashtable?
$Domains = @{}
$SomeDomain = 'abc.com'
$Domains[$SomeDomain] = New-Object -TypeName System.Data.Datatable

Open in new window

0
 
LVL 13

Author Closing Comment

by:Dustin Saunders
ID: 41731410
Ah, yeah good idea that would work just fine.  Thanks!
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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 antispam), the admini…

734 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