*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***
Product, version and build: 2017, 5.4.136
32 or 64 bit version of product: 64
Operating system: W2K12R2
32 or 64 bit OS: 64
*** Please add details and screenshots as needed below. ***
Hi,
I have a form which manages computers: check processes, services, event viewer, get users logged on etc ....
Now when the computer is not online, it 'd like to have a textbox showing "$computername offline" or "$computernam online"
Made this and it works fine. However, since it is continuously running, it freezes the form. So I'd need to make a job for it.
There I'm stuck, because the job should just keep on running in the background each time ... and no output to be generated because there is no output.
Below what I have so far. Please advise.
J.
Code: Select all
Add-JobTracker -Name 'CheckStatusComputer' `
-JobScript {
$SleepTimeOut = 3
Do
{
$available = $Null
$notavailable = $Null
if (Test-Connection -ComputerName $using:computername -Count 1 -ea silentlycontinue)
{
$computerlabelonlineoffline.Text = "$ComputerName online"
$computerlabelonlineoffline.ForeColor = "green"
}
else
{
$computerlabelonlineoffline.Text = "$ComputerName OFFLINE"
$computerlabelonlineoffline.ForeColor = "red"
$computerlabelonlineoffline.Font = "bold"
}
sleep $SleepTimeOut
}
while ($Exit -ne $True)
}`
-CompletedScript {
Param ($Job)
$Result = Receive-Job -Job $Job
Invoke-Item $Result
-UpdateScript {
Param ($Job)
}`