Skip to content

Powershell to SQlite - Need help with Parameters as a variable #124

Closed Answered by mithrandyr
SubScrubber asked this question in Q&A
Discussion options

You must be logged in to vote

Your example is a little complicated (I suspect in order to handle other scenarios), so I'll reframe to show a simpler version that hopefully will make clear how to leverage the module to do this. (that said v2 will make this easier... and i'm almost done testing the changes).

#open an inmemory db connection
Open-SQLiteConnection

#create a table
Invoke-SqlUpdate -Query "CREATE TABLE computer_process (id int, name text, path text)" | Out-Null

#get processes to store
$data = Get-Process | Select-Object -first 15 Id, ProcessName, Path

#store data
$query = "INSERT INTO computer_process (id, name, path) VALUES (@id, @name, @path)"
foreach($d in $data) {
    Invoke-SqlUpdate -Query $query -P…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@mithrandyr
Comment options

Comment options

You must be logged in to vote
1 reply
@mithrandyr
Comment options

Answer selected by mithrandyr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants