I apologize for the very basic question.
I am a PowerShell novice and I am creating two scripts.
The first script will populate a variable, let’s say “$mytable” with personal information like:
Name
Family Name
Age
Social Secutiry Number
Telephone number
I don’t know how many people will be managed each time, I can say only they will be less than 100.
Which kind of variable should I create? In other languages I would create a stucture, what is the right way for PowerShell?
Once created the variable I need to pass it to the second script like a parameter.
The second script will examine each element with a statement like:
“for each person in $mytable” do something.
What is the right way to create a variable to fit my needs?
Is there any sample I can start from?
Regards
marius
Consider “Learn PowerShell Toolmaking in a Month of Lunches” or “The PowerShell Scripting & Toolmaking Book” as very valuable in getting you on the right path in this regard. You’re perilously close to heading on the Dark Path of Painfulness because PowerShell isn’t like most other languages.
You want to use New-Object to create a new PSObject, and then populate it with properties for Name, Age, etc. You want to Write-Output that to the pipeline, one object at a time, so that the pipeline can carry the objects to the next command. That next command can use pipeline parameter binding to “pick up” the objects and process them however it needs.
Either of the two above books will really put you on the Light Path of Righteousness and do a lot to help you understand how PowerShell “wants” to do this kind of thing.