hi,
$test= {
1
[void][Reflection.Assembly]::Load("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
$sqlConnectionString= 'Data Source=xama;Initial Catalog=adm;Integrated Security=False;User ID=xxx;Password="xxxx"'
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection ($sqlConnectionString)
$sqlConnection|Out-File $dir\test.txt -Append
$sqlConnection.Open()
}
Add-JobTracker -Name 'job' -JobScript $test -UpdateScript {
param ($job)
$results = Receive-Job -Job $Job | Select-Object -Last 1
} -CompletedScript {
Param ($Job)
}
job tracker without working, ok.
But in JobTracker variable is empty.
Any ideas?
sql connect jobtracker
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: sql connect jobtracker
Jobtracker cannot create a connection. It can return data but the connection will be closed whe the job completes.
You do not need to load System.Data. It comes built into a PowerShell Session.
Test at a prompt like this:
You do not need to load System.Data. It comes built into a PowerShell Session.
Test at a prompt like this:
- $test = {
- $sqlConnectionString = 'Data Source=xama;Initial Catalog=adm;Integrated Security=False;User ID=xxx;Password="xxxx"'
- $sqlConnection = New-Object System.Data.SqlClient.SqlConnection ($sqlConnectionString)
- $sqlConnection.Open()
- $sqlConnection|select *
- }
- Start-Job -ScriptBlock $test | Wait-Job | Receive-Job
- Gordeev Alexaender
- Posts: 10
- Last visit: Tue Jan 09, 2018 1:50 am
Re: sql connect jobtracker
$MainForm_Load={
#TODO: Initialize Form Controls here
}
$test = {
$sqlConnectionString = 'Data Source=xxx;Initial Catalog=xxx;Integrated Security=False;User ID=adm;Password=xxx'
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection ($sqlConnectionString)
$sqlConnection.Open()
$sqlConnection | select *
}
$button1_Click={
#TODO: Place custom script here
Start-Job -ScriptBlock $test | Wait-Job | Receive-Job
}
Interesting. If I run the script then everything is OK. If in windows form, then the result is zero. What am I doing wrong?
#TODO: Initialize Form Controls here
}
$test = {
$sqlConnectionString = 'Data Source=xxx;Initial Catalog=xxx;Integrated Security=False;User ID=adm;Password=xxx'
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection ($sqlConnectionString)
$sqlConnection.Open()
$sqlConnection | select *
}
$button1_Click={
#TODO: Place custom script here
Start-Job -ScriptBlock $test | Wait-Job | Receive-Job
}
Interesting. If I run the script then everything is OK. If in windows form, then the result is zero. What am I doing wrong?
Re: sql connect jobtracker
I asked you to run it at a prompt. Not is a form. You cannot see any output in a form. Forms do not work like you think.
Open PowerShell and paste my code in and look at the output.
Open PowerShell and paste my code in and look at the output.
- Gordeev Alexaender
- Posts: 10
- Last visit: Tue Jan 09, 2018 1:50 am
Re: sql connect jobtracker
I am very sorry.
I wrote debug itself, and made variable for the script block. Everything works perfectly. I feel very sorry, sorry again ((
PS How do I know the form. That is why in the code did export to txt. Something like a log.
I wrote debug itself, and made variable for the script block. Everything works perfectly. I feel very sorry, sorry again ((
PS How do I know the form. That is why in the code did export to txt. Something like a log.