Support Forums

Powershell Studio 2015 visual indicator update real time?

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.
User avatar
stratagem
Posts: 6
Joined: Tue Jan 26, 2016 11:27 am

Powershell Studio 2015 visual indicator update real time?

Postby stratagem » Wed Feb 10, 2016 6:16 am

Sorry for the poor subject line. I'm not sure how to word it exactly.

What I'd like to do is create some visual indicators for the users showing if a service is running or not. Maybe change a label box or picture box to red / green depending on the status? Is it possible to have this job running in the background separate from the button clicks and have it update the boxes in real time?
User avatar
jvierra
Posts: 9699
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Powershell Studio 2015 visual indicator update real time?

Postby jvierra » Wed Feb 10, 2016 8:22 am

Yes - You can use a timer tick to do this.
User avatar
stratagem
Posts: 6
Joined: Tue Jan 26, 2016 11:27 am

Re: Powershell Studio 2015 visual indicator update real time?

Postby stratagem » Wed Feb 10, 2016 10:06 am

Thanks! I'll read more on timers.
User avatar
stratagem
Posts: 6
Joined: Tue Jan 26, 2016 11:27 am

Re: Powershell Studio 2015 visual indicator update real time?

Postby stratagem » Thu Feb 11, 2016 9:50 am

I'm having a hard time working this out.

Would it be best to create this function, if it should be a function, in the form_load section or before that? And then have a function for each label call on the timer?

Sorry, I'm still learning Powershell and most of my scripts have been one-liners. I still have a long ways to go...
User avatar
jvierra
Posts: 9699
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Powershell Studio 2015 visual indicator update real time?

Postby jvierra » Thu Feb 11, 2016 10:14 am

Why do you need functions to change a labels color?
User avatar
stratagem
Posts: 6
Joined: Tue Jan 26, 2016 11:27 am

Re: Powershell Studio 2015 visual indicator update real time?

Postby stratagem » Thu Feb 11, 2016 10:22 am

I'm using this method as feedback for the end users. Right now when I click start or stop it works but it doesn't provide any indication that it's finished. So the user has to trust that it is working and remember which services they have either started or stopped.

Functions might not be what I need. I'm unsure on how to solve this problem.
User avatar
jvierra
Posts: 9699
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Powershell Studio 2015 visual indicator update real time?

Postby jvierra » Thu Feb 11, 2016 12:50 pm

What does that have to d with functions.

You are way too vague for me to be able to answer. What are you doing? What and how many services? What is the purpose?
User avatar
jvierra
Posts: 9699
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Powershell Studio 2015 visual indicator update real time?

Postby jvierra » Thu Feb 11, 2016 2:10 pm

You asked bout timers. What do the timer and the button have to do with each other?
User avatar
stratagem
Posts: 6
Joined: Tue Jan 26, 2016 11:27 am

Re: Powershell Studio 2015 visual indicator update real time?

Postby stratagem » Fri Feb 12, 2016 5:56 am

Sorry, not trying to be vague.

It's a small form that stop/starts about 15 different services spread over 3 different servers. The labels themselves are only there to show if the service is running. That's it.

So something like this...

If ($Service.Status -eq "Running")
{
$label1.Text = "Running"

}
Else { $label1.Text = "Stopped" }

}

I need it on a timer or something else that will automatically update the labels every X amount of seconds.
Hopefully that clears it up.
User avatar
jvierra
Posts: 9699
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Powershell Studio 2015 visual indicator update real time?

Postby jvierra » Fri Feb 12, 2016 6:18 am

Here is an easier way to handle that..

$timer_tick={
$services= 'service1', 'service2', 'service3'
$services=$computers|
ForEach-Object{
Get-Service -Computer $_ -Name $services
} |
select MachineName,DisplayName, Status
 
$datagridview.DataSource=[collections.arraylist]$services
}


We can also use a list view with images or a checked listbox.

Return to “PowerShell GUIs”

Who is online

Users browsing this forum: No registered users and 8 guests