Replies: 2 comments 1 reply
-
Would you please post up the command as it works in PowerShell (with the relevant line breaks) and I will have a look - thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, My oneliner command that works: $password = "<password>" | ConvertTo-SecureString -asPlainText -Force; $username = "<username>"; $credential = New-Object System.Management.Automation.PSCredential ($username, $password); Invoke-Command -Credential $credential -ScriptBlock { $query = " INSERT INTO <table> (<col1>, <col2>, <col3>, <col4>, <col5>) VALUES (<val1>, '<val2>', '<val3>', '<val4>', '<val5>')"; Invoke-Sqlcmd -ServerInstance localhost -Database <db> -Query $query } -computername "<server>" here is the line by line version: $password = "<password>" | ConvertTo-SecureString -asPlainText -Force;
$username = "<username>";
$credential = New-Object System.Management.Automation.PSCredential ($username, $password);
Invoke-Command -Credential $credential -ScriptBlock {
$query = " INSERT INTO <table> (<col1>, <col2>, <col3>, <col4>, <col5>) VALUES (<val1>, '<val2>', '<val3>', '<val4>', '<val5>')";
Invoke-Sqlcmd -ServerInstance localhost -Database <db> -Query $query
} -computername "<server>" Thank you! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I want to write multiline command, but it does not work. I thought it may because of the syntax and tried writing differently the quotation marks to fix but could not make it. Command works normally via cli and ghost user is the same. Here is the json file:
How should I write this command? Could you please help?
Beta Was this translation helpful? Give feedback.
All reactions