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

**URL:** <https://forums.powershell.org/t/best-practices-for-outputting-objects-inserting-via-invoke-sqlcmd/12112>\
**Category:** PowerShell Help\
**Created:** [February 28, 2019, 7:23pm UTC](https://forums.powershell.org/t/best-practices-for-outputting-objects-inserting-via-invoke-sqlcmd/12112 "2019-02-28T19:23:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmac](https://avatars.discourse-cdn.com/v4/letter/c/ee7513/32.png) [@cmac](https://forums.powershell.org/u/cmac)\
**Post date:** [February 28, 2019, 7:23pm UTC](https://forums.powershell.org/t/best-practices-for-outputting-objects-inserting-via-invoke-sqlcmd/12112/1 "2019-02-28T19:23:20Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/best-practices-for-outputting-objects-inserting-via-invoke-sqlcmd/12112/2 "2024-05-16T20:33:13Z")

</div>


