Need a Powershell script to change css code

Hi Experts,

I'm quiet new to PowerShell scripting. What I need is the following;

I've got a simple HTML / CSS website. The site shows some computer icons that users can click on to start a RDP session to a workstation. Below each icon I want the network status of that specific workstation shown.

So the script needs to ping the workstations from, for example a txt file with a list of ip addresses, and then show the text 'online' or 'offline' below the icons of that workstations. The background color must be green or red.

Can I build a css file that creates a class for every PC that's in the list in the txt file?  I know I asked this here before, but I haven't found a good solution yet.
Who is Participating?
Alexandre SimõesManager / Technology SpecialistCommented:
I don't this this will ever work properly mate...

If I well understand you you want to change the CSS to reflect the servers status instead of doing it server-side right?
The main problem I see here is actually related with the browsers cache.
If the name of the CSS file doesn't change, the browser won't download it again, sometime not even with a Ctrl-F5 (IE is a bit unstable on this and Opera you can well forget about it).
So, even if you change the CSS file the browser won't pick it or you'll never be 100% sure if he picked it or not.

Your most reliable way to implement this is server side or client-side with AJAX calls and timers.
SvenIAAuthor Commented:
That's a good one, didn't think of that.
SvenIAAuthor Commented:
Is it possible to refresh an IE browser window periodically with Powershell?
Alexandre SimõesManager / Technology SpecialistCommented:
I don't know but It won't make much difference anyway mate.
You can't neither easily nor reliably control the way browsers reload their resources upon refresh.

Sure there are a lot of tricks, but they usually involve more than a mere Ctrl-F5.
Without changing the HTML of the page I would say it's impossible.

For instance, you can add some "special" tags to the page header to disable browsers cache:
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

Open in new window

But this will impact the whole website resources caching which probably you don't want and still... if that thing you want to do is really important I wouldn't trust this "hack" myself.

Is it really out of the question to do it server-side?
SvenIAAuthor Commented:
Thanks for the information!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.