need to create an arrary of objects, each object has 2 properties
hi,
i have requirement create array of objects , loop on it. each object in array needs have 2 properties called:
- dbname
- projectname
the looping bit i'm ok i'm not sure arrays , how "new" object out of nothing. in .net parlance create struct containing 2 string properties , create array of instances of struct.
hope makes sense. advice appreciated.
thanks
jamie
p.s. powershell 1.0
http://sqlblog.com/blogs/jamie_thomson/ | @jamiet | me
new-object friend
for example
$objarray = @()
$tmpobject = new-object psobject
#you can put next 3 lines in loop , construct array of objects
$tmpobject | add-member -membertype noteproperty -name "name" -value "test"
$tmpobject | add-member -membertype noteproperty -name "age" -value 30
$objarray += $tmpobject
ravikanth
http://www.ravichaganti.com/blog
twitter: @ravikanth
powershell 2.0 remoting - ebook
Windows Server > Windows PowerShell
Comments
Post a Comment