sql server - Powershell to SQL database -
my initial post how pass data directly pipeline (remote) sql database. writing csv database did not work amount of data working - on 2 million files querying.
below final script came with. scans file server, filters in pipeline, creates psobject file attributes , stores attributes of object variables. variables passed sql query string. it's bit cumbersome, not see way file attributes read directly query string.
i needed way run remotely.
with of invoke-sqlcmd2
can write , read data sql server database. more info here.
i'm not sure think cmdlet not accept pipeline input. best bet transform code foreach
structure , invoke cmdlet invoke-sqlcmd2
every time want insert
or else.
something this:
$csv = get-content -path "d:\fs01-user-files\$name.csv" foreach ($line in $csv) { invoke-sqlcmd2 @sqlparams -query " insert $sqltable (filename, data) values('$line.filename', '$($line.data)')" }
how can run account has domain privileges?
you can set scheduled task
runs user password stored. task can triggered other users have rdp access server scheduled task
has been created.
Comments
Post a Comment