I've got a directory with a bunch of SQL files ( queries ) that I'd like to execute.
What's the best way to go about it?
I can do it static but that seems a little inefficient if other files are added.
invoke-sqlcmd -inputfile "c:\temp\adduserl.sql" -serverinstance "10.129.221.91" -database "GoodOne" -username "user" -password "pw1"
invoke-sqlcmd -inputfile "c:\temp\addaddressesl.sql" -serverinstance "10.129.221.91" -database "GoodOne" -username "user" -password "pw1"
Perhaps a for loop of some sorts?
Related
I have a PowerShell script that creates a local user and adds to the Admin group it's working when I'm running it but I've made an exe file from it. after execution, nothing happens
$UserName = Read-Host "UserName"
$UserPassword = Read-Host "Password" -AsSecureString
New-LocalUser -Name $UserName -Password $UserPassword -description 'NewUser'
Add-LocalGroupMember -Group "Administrators" -Member ("$UserName") -Verbose
I've made exe file using the "PS2exe" module and "iexpress" can somebody help to fix it or create Log files for this exe
I am trying to export a h2 database using the script command. After the export, I am only getting one line in the resulting test.sql - CREATE USER IF NOT EXISTS SA SALT '05767239a3f290a0'....
I tried using the SQL command SCRIPT and also the command line, as follows. The result is the same in both cases:
SCRIPT TO "myfolder/test.sql"
java -cp h2-1.4.197.jar org.h2.tools.Script -url "jdbc:h2:~/test;AUTO_SERVER=TRUE;MV_STORE=FALSE" -user sa -password gw -script test.sql
What could I be doing wrong?
Also, does the script command export the information_schema?
Is there a way to call specific functions in a jython script through the wsadmin program?
# BusAndBusMemeber.py
def devCreateBus:
AdminTask.createSIBus('[-bus intjmsbus -description [SIBus intjmsbus] -busSecurity false]')
AdminTask.addSIBusMember('[-bus intjmsbus -node ctgNode01 -server MXServer]')
AdminConfig.save()
def devDeleteBus:
AdminTask.deleteSIBus('[-bus intjmsbus]')
AdminConfig.save()
from server cmd prompt:
C:\IBM\WebSphere....\bin> wsadmin -conntype SOAP -user myUsername -password
myPassword -lang jython -f BusAndBusMember.py devCreateBus
Or
C:\IBM\WebSphere....\bin> wsadmin -conntype SOAP -user myUsername -password
myPassword -lang jython -f BusAndBusMember.py [devCreateBus]
so far the only way I've been able to execute the jython script is by simply scripting out the AdminTasks.
thanks.
It is a bit of a hack but you can append this to your script:
globals()[sys.argv[0]]()
An alternative is to keep your functions in this file and write a second python script that does the logic of which functions to call:
import sys
execfile("BusAndBusMemeber.py")
if sys.argv[0] == "devCreateBus":
devCreateBus();
else:
print("Unknown arg %s" % sys.argv[0])
You could also combine the -profile and -c options like:
.wsadmin.sh -profile "functions.py" -c "print devCreateBus()"
It will still run through the whole -profile script so you probably just want functions in there not a "main".
I am trying to import a certificate on a VM.
I am doing the following script:
Start-VM -Name $NewVmName
Copy-VMFile -Name $NewVmName -SourcePath ".\certificate.pfx" -DestinationPath "C:\certificate.pfx" -CreateFullPath -FileSource Host
$Password = "test" | ConvertTo-SecureString -asPlainText -Force
Invoke-Command -VMName $NewVmName -Credential $LocalCredential -ScriptBlock {
Import-PfxCertificate -FilePath "C:\certificate.pfx" -CertStoreLocation Cert:\LocalMachine\My -Password $Password
}
So the certificate store location is indicated. However, when I run this script, Windows prompts me to know in which store I want to import the certificate:
How come? what do I do wrong? I want the certificate to be imported without any user interactions of course.
Thanks!
I am calling mongoexport using shell script but it keeps failing. My script is :--
mongo localhost:27038/admin -u test -p mongo123 < mongoexport.js
and my mongoexport.js file is :--
use db1
mongoexport --type=csv --fields _id -q '{"_id": "323549991" , "cat" : "ABC"}' --out report.csv
But every time I run it fails with below error :--
switched to db db1
2018-01-10T17:36:15.495+0000 E QUERY [thread1] SyntaxError: missing ; before statement #(shell):1:14
bye
Now I am not sure where exactly I am messing up the syntax .
Regards.
It looks like you are connecting to your mongo. You don't need to do that in order to execute mongoexport.
You just need to connect to your host (not mongo). Take a look at the official documentation
This data resides on the MongoDB instance located on the host
mongodb1.example.net running on port 37017, which requires the
username user and the password pass.
mongoexport --host mongodb1.example.net --port 37017 --username user
--password "pass" --collection contacts --db marketing --out mdb1-examplenet.json
In your case it should look like that (Untested)
mongoexport --host localhost --port 27038 --username test --password "mongo123" --db admin --collection db1 --type=csv --fields _id -q '{"_id": "323549991" , "cat" : "ABC"}' --out report.csv
I assumed your database is called admin and your collection db1, if not replace them accordingly.