Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Need a Powershell script to change css code

Posted on 2014-07-09
Medium Priority
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 2000 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

WEBINAR - Latest Cyber Tips for Defense

Join the WatchGuard Threat Research Team on October 26th for an informative webinar featuring expert tips and tricks for defending your organization from today's latest cyber threats. Don't leave yourself vulnerable to attack. Register for the webinar today!

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

596 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