Dynamically create objects

Welcome Forums General PowerShell Q&A Dynamically create objects

Viewing 1 reply thread
  • Author
    • #199337
      Topics: 7
      Replies: 10
      Points: 113
      Rank: Participant


      I want to create chart with ping result from few servers (they addresses are readed from file). It require to create new series for each server using command:

      $series1 = New-Object -TypeName System.Windows.Forms.DataVisualization.Charting.Series //for fist server,
      $series2 = New-Object -TypeName System.Windows.Forms.DataVisualization.Charting.Series //for second server

      Now I wanted to redesign script that it will count number of servers from file, and based on that number, created the right number of $series.
      For example “something” like in the code below:

      foreach ($server in $servers.PSObject.Properties.Name -notmatch "timestamp"){
      New-Variable "Series$i" 
      "Series$i" = New-Object -TypeName 
      $i ++

      But this is not working… How can I resolve this problem?

      • This topic was modified 2 months, 1 week ago by kolaborek08.
      • This topic was modified 2 months, 1 week ago by kolaborek08.
    • #199370
      Topics: 12
      Replies: 1489
      Points: 1,987
      Helping Hand
      Rank: Community Hero

      Take a look at this thread:


      Also note that there are other options rather than this charting also referenced in the above thread.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.