Question : Powershell Write to Database

The following code was written to return the name of the SQL Server instances running on a particular server. Currently, it just outputs the results to the screen. Does anyone know how I can persist the return results to a table in a SQL Server database?
Code Snippet:
1:
Get-Process -name "sqlservr" | Sort-Object -Property ID | ForEach-Object -process {Get-WMIObject Win32_Service -filter ("ProcessID =" + $_.Id)} | Format-Table -autosize -Property ProcessID, Name
Open in New Window Select All

Answer : Powershell Write to Database

If you have SQL 2008 it is very simple with the 2008 Powershell provider.

If not.. try this http://www.leeholmes.com/blog/InteractingWithSQLDatabasesInPowerShellInvokeSqlCommand.aspx
Random Solutions  
 
programming4us programming4us