Anyone Able to Help Out a PS Newbie?

Welcome Forums General PowerShell Q&A Anyone Able to Help Out a PS Newbie?

Viewing 2 reply threads
  • Author
    • #191194
      Topics: 1
      Replies: 1
      Points: -6
      Rank: Member

      Hi all,

      Looking for some assistance please.

      I am attempting to use PS to import a list of IP address subnets (with individual, corresponding, site names) from CSV and for each of them, create additional items and then export the result to another CSV.

      In the import CSV there are two columns, “Site Name” and “IP Address” e.g.

      Site Name IP Address

      I’d like to use PS to ultimately output a separate (one column) CSV containing something along the lines of the following:

      ConnectionName; ConnectionAddress; FolderName
      Test1 Host1;; Test1 Host1
      Test1 Host2;; Test1 Host2
      Test1 Host3;; Test1 Host3
      Test2 Host1;; Test2 Host1
      Test2 Host2;; Test2 Host2
      Test2 Host3;; Test2 Host3
      Test3 Host1;; Test3 Host1
      Test3 Host2;; Test3 Host2
      Test3 Host3;; Test3 Host3

      The idea being that the output CSV can be read by a system in order to create a hierarchy.

      I’m aware (roughly) I’m looking at usingĀ  “import-csv”, “foreach” and, I’m assuming, “new-item” but I’m not entirely sure how to put it all together.

      If anyone could point me in the right direction I’d appreciate it.



    • #191212
      Topics: 0
      Replies: 24
      Points: 158
      Helping Hand
      Rank: Participant
      Import-Csv c:\temp\subnets.csv | ForEach-Object {
        for ($x=1; $x -lt 4; $x++) {
          $subnet = $_.'IP Address'.Substring(0,$_.'IP Address'.Length-1)
          $_.'Site Name' + " Host$x;$subnet$x;" + $_.'Site Name' + " Host$x"
    • #191632
      Topics: 1
      Replies: 1
      Points: -6
      Rank: Member

      Hi Seam,

      Thanks for taking the time to reply. Very helpful of you. Much appreciated.

Viewing 2 reply threads
  • The topic ‘Anyone Able to Help Out a PS Newbie?’ is closed to new replies.