Hyphen (-) and PS

Welcome Forums General PowerShell Q&A Hyphen (-) and PS

Viewing 2 reply threads
  • Author
    Posts
    • #203580
      Participant
      Topics: 11
      Replies: 22
      Points: 122
      Rank: Participant

      Hi, is there any restrictions on using the hyphen in PS?

      I am importing records from windows firewall

      import-csv -Path $FirewallLog -Delimiter " " -Header Date, Time, Action, Protocol, src-ip, dst-ip, srcport......
      

      when I try to assign for example

      $mySrc = $_.src-ip

      I get a suiggly red line under src-ip. I tried the tick symbol to escape but it did not work

      $mySrc = $_.src`-ip

      Thanks for your help

      • This topic was modified 1 month, 2 weeks ago by Salam ELIAS.
      • This topic was modified 1 month, 1 week ago by kvprasoon. Reason: code formatting
      • This topic was modified 1 month, 1 week ago by kvprasoon.
      • This topic was modified 1 month, 1 week ago by kvprasoon.
    • #203586
      Participant
      Topics: 4
      Replies: 1908
      Points: 4,259
      Helping Hand
      Rank: Community Hero
      $mySrc = $_.'src-ip'

      or

      $mySrc = $_."src-ip"
    • #203592
      Participant
      Topics: 11
      Replies: 22
      Points: 122
      Rank: Participant

      Lovely, it is working like a charm, thanks

Viewing 2 reply threads
  • You must be logged in to reply to this topic.