Best practices for outputting objects (Inserting via invoke-SQLCMD)

Welcome Forums General PowerShell Q&A Best practices for outputting objects (Inserting via invoke-SQLCMD)

This topic contains 0 replies, has 1 voice, and was last updated by  cmac76 1 month, 2 weeks ago.

  • Author
  • #142160

    Points: 75
    Rank: Member

    Hi all,

    I am after some advice from the community with regards to how best handle the following Scenario:

    In reference to the following Best Practices when writing PowerShell tools

    *A Tool does one thing.
    *Objects are the only form of pipeline output emitted.

    I have written a tool to Insert data into a SQL Database via Invoke-SQLCMD (I am generalizing the code and removing a lot of it  to protect identity)

    $ComputerName = "ServerA"
    $Geolocation = "ACountry"
    Invoke-Sqlcmd -Database $Database -ServerInstance $ServerInstance -Query "Insert into Details(ComputerName, Geolocation) VALUES ('$ComputerName','$Geolocation')"

    When this runs you get no feedback from PowerShell and I cant see anything I can use on the pipeline- but it certainly is adding data into the DB, so something is happening there.... I am aware of new parameters with invoke-sqlcmd like -outputas  but playing around with these gives me nothing.

    How do I design the above so that it outputs objects.. but also not adding any extra activities in the tool..

You must be logged in to reply to this topic.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort