Need a Powershell script to change css code

Posted on 2014-07-09
Last Modified: 2014-07-16
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.
Question by:SvenIA
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 30

Accepted Solution

Alexandre Simões earned 500 total points
ID: 40184646
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.

Author Comment

ID: 40184669
That's a good one, didn't think of that.

Author Comment

ID: 40184729
Is it possible to refresh an IE browser window periodically with Powershell?
LVL 30

Expert Comment

by:Alexandre Simões
ID: 40184746
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?

Author Closing Comment

ID: 40198910
Thanks for the information!

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at Browse or search based on font properties or name to find a suitable font for…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question