none
Best way to select from sql table and insert into another table from Powershell RRS feed

  • Question

  • Hi, I have made a small script, I want to collect some information from all my SQL instances, and collect this in a central database.

    I am doing this with powershell, and using the invoke-sqlcmd cmdlet.

    The script looks like this, and the input file just for now gets 3 columns from the instance.

    I have created a table where I want to put the data.

    Import-Module "sqlps" -Verbose
    cls
    
    $SQLcmd = invoke-sqlcmd -ServerInstance "SQL019T\H1" -inputFile "\\server\Scripts\SQL\SQL_rapport_003.sql" | SELECT Instance, ServerName, CollectionTime 

     

    I am wondering what to put next in the script, to insert this output into the central table.

    Wednesday, November 22, 2017 12:28 PM

Answers