Add switch statements to script

Welcome Forums General PowerShell Q&A Add switch statements to script

Viewing 5 reply threads
  • Author
    Posts
    • #280191
      Participant
      Topics: 2
      Replies: 8
      Points: 30
      Rank: Member

       

      I want to add a few other switches to this script. truncate table and csvlinecnt and loadcnt. I would like to clear the
      table before loading, and count the number of lines to load in csv and count records loaded.

      Maybe even put any output from script in an email for load tracing.

      Thanks.

    • #280263
      Senior Moderator
      Topics: 9
      Replies: 1449
      Points: 5,426
      Helping Hand
      Rank: Community MVP

      Are you the author of this script ? let us know little more on what problem are you facing here.

    • #280281
      Participant
      Topics: 2
      Replies: 8
      Points: 30
      Rank: Member

      This was a script I asked for some help creating, as I had something similar, but it wasn’t doing the switch’s in the original design. I would like to add more functionality of record counts both of the csv and “what loaded to SQL”. Then I thought
      adding a TruncateTable since I would always be loading a Staging table.

      Thanks.

    • #284086
      Participant
      Topics: 2
      Replies: 8
      Points: 30
      Rank: Member

      Any help in adding a few new options to this script?

       

      Thanks

    • #284101
      Participant
      Topics: 5
      Replies: 253
      Points: 1,007
      Helping Hand
      Rank: Community Hero

      Sounds like when you say “switch statements” you mean switch parameters.  As your script is now, I don’t see any switch statements.  See Get-Help about_switch

      To add switch parameters, just put them in the param block and reference them in the script where appropriate.  These will be simply True of False depending on if the caller included the switch, so you can use a simple if statement like you see in line 90 and 122 of your current posted script.

      Recommend you refine your new requirements some more and try to implement the code as much as you can, then maybe someone can help you with logic/errors as needed.  Right now what you are trying to accomplish seems a little vague to me.

    • #284785
      Participant
      Topics: 2
      Replies: 8
      Points: 30
      Rank: Member

      One of the requirements was to Truncate Table, the other where to verify records in csv match to what was loaded.
      If not send alert of the records loaded didn’t match records received.

       

       

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