3 answers
Hi allybrbs,
Since your HTML files already seem to be made, you could insert placeholders instead of the information to display, and use PowerShell to replace the placeholders with the information you want to include, using them as templates. This way, you can use your HTML files as templates to generate filled HTML files with the desired information.
For example, let’s say the file
Then, in your PowerShell script where you determine the machine name and store it in a variable named, for example,
(untested, I’m not on Windows)
And you have created a file
It’s just an idea... to do what you want based on what you seem to have already done.
Dal
Since your HTML files already seem to be made, you could insert placeholders instead of the information to display, and use PowerShell to replace the placeholders with the information you want to include, using them as templates. This way, you can use your HTML files as templates to generate filled HTML files with the desired information.
For example, let’s say the file
template-infos.htmlcontains a
<div>that should display the machine name. You would put
zzzNOMMACHINEzzzwhere it should appear.
Then, in your PowerShell script where you determine the machine name and store it in a variable named, for example,
$nommachine, you would do something like:
cat template-infos.html | %{$_ -replace "zzzNOMMACHINEzzz",$nommachine} > infos.html (untested, I’m not on Windows)
And you have created a file
infos.htmlthat can be displayed by a browser or an HTML interpreter, including the hardcoded information in this static page, and that from
template-infos.html.
It’s just an idea... to do what you want based on what you seem to have already done.
Dal
Hello,
Firstly... HTML doesn’t execute any scripts...
HTML is a markup language (not a programming language) that indicates to a web browser how the content to be displayed is structured.
Next, I see that in your code you have PHP.
Now... it’s important to know that PHP is executed on the SERVER side and not on the client side.
As for retrieving information directly from the client’s machine... no web page, for obvious security reasons..., can do that!
What I find hard to understand is why you want to "retrieve" the information when the user visits the page... is that correct??
Logically, for asset management, information retrieval scripts (like the ones you’ve written in PowerShell) are executed automatically on all user machines (via an ERP -> Active Directory) or, at the very least, by launching them at startup.
This information is then centralized in a database
From there, you can retrieve the info (in PHP for example) and display it on your web page.
But when I see the example of the returned result... I have the impression that PHP is not being interpreted...
Are your web pages hosted locally on the user's machine or on a server? A server where Apache/PHP has been installed and is operational??
In short... there are many inconsistencies in your request and certainly in your research/tests...
Please clarify as best as you can:
- The needs
- The constraints
- The environment (OS... web server..., file locations..... etc ...)
--
Best regards,
Jordane
Firstly... HTML doesn’t execute any scripts...
HTML is a markup language (not a programming language) that indicates to a web browser how the content to be displayed is structured.
Next, I see that in your code you have PHP.
Now... it’s important to know that PHP is executed on the SERVER side and not on the client side.
As for retrieving information directly from the client’s machine... no web page, for obvious security reasons..., can do that!
What I find hard to understand is why you want to "retrieve" the information when the user visits the page... is that correct??
Logically, for asset management, information retrieval scripts (like the ones you’ve written in PowerShell) are executed automatically on all user machines (via an ERP -> Active Directory) or, at the very least, by launching them at startup.
This information is then centralized in a database
From there, you can retrieve the info (in PHP for example) and display it on your web page.
But when I see the example of the returned result... I have the impression that PHP is not being interpreted...
Are your web pages hosted locally on the user's machine or on a server? A server where Apache/PHP has been installed and is operational??
In short... there are many inconsistencies in your request and certainly in your research/tests...
Please clarify as best as you can:
- The needs
- The constraints
- The environment (OS... web server..., file locations..... etc ...)
--
Best regards,
Jordane
Hello Jordane45,
Well, I think the needs, constraints, etc. are well defined: I need to create a web page in HTML that displays (in my table) technical information about a machine for the intervention teams. This page will then be displayed in the software center (which only shows HTML pages). I must only use equipment that is already available on the PC running Win10 (so no software or anything else, and some PCs are running Win7) and the file locations will be on each machine through SCCM as I mentioned earlier.
I don't see what I should add, everything has already been said..
Yet all the web pages retrieve information from our PCs, all without exception. If others can do it, I should be able to do it too.. Especially since these are employees, so there are no security issues, it's just random information like the machine name, IP address, disk capacities, etc.
I don't see what you don't understand.. When the user goes to the software center, all the information will be grouped together, what is unclear???
Once again, there is no server, as it is a local page on each PC via SCCM.
If there is no database, I don't see how I can use your technique, especially since I need to stick to the principle of an intranet page.
I believe you must have misread my topic because most of the things you are asking for are already given or specified.
Please provide your concrete solution if you have one, because for now I don't understand where you're coming from unfortunately...
Well, I think the needs, constraints, etc. are well defined: I need to create a web page in HTML that displays (in my table) technical information about a machine for the intervention teams. This page will then be displayed in the software center (which only shows HTML pages). I must only use equipment that is already available on the PC running Win10 (so no software or anything else, and some PCs are running Win7) and the file locations will be on each machine through SCCM as I mentioned earlier.
I don't see what I should add, everything has already been said..
Yet all the web pages retrieve information from our PCs, all without exception. If others can do it, I should be able to do it too.. Especially since these are employees, so there are no security issues, it's just random information like the machine name, IP address, disk capacities, etc.
I don't see what you don't understand.. When the user goes to the software center, all the information will be grouped together, what is unclear???
Once again, there is no server, as it is a local page on each PC via SCCM.
If there is no database, I don't see how I can use your technique, especially since I need to stick to the principle of an intranet page.
I believe you must have misread my topic because most of the things you are asking for are already given or specified.
Please provide your concrete solution if you have one, because for now I don't understand where you're coming from unfortunately...
So...
So you can't run a language like PHP (like in the examples you tested).
Knowing that just before you stated
Look at what intranet means...
You can understand my confusion given the mistakes you introduced in your explanation..
Not to mention the examples you tested containing PHP...
The web pages... which ones???
But since the HTML files will be placed directly on the user's machine...
Don't you think you're approaching the problem the wrong way...
I think it's the scripts that create the HTML files... and not the HTML that "calls" the scripts....
Once again, there is no server, as this is a local page on each PC via SCCM.
If there is no database, I don't see how I can use your technique, especially since I have to stick to the principle of an intranet page.
So you can't run a language like PHP (like in the examples you tested).
Knowing that just before you stated
having an intranet page
Look at what intranet means...
I believe you misread my topic because most of the things you're asking for have already been given or specified.
You can understand my confusion given the mistakes you introduced in your explanation..
Not to mention the examples you tested containing PHP...
Yet all web pages retrieve information from our PCs, all without exception. If others can do it, I should be able to do it too..
The web pages... which ones???
But since the HTML files will be placed directly on the user's machine...
Don't you think you're approaching the problem the wrong way...
I think it's the scripts that create the HTML files... and not the HTML that "calls" the scripts....
But precisely, I do NOT use a server since the page will be stored at the SCCM level, so I don't see what the problem is. I know what intranet means, and I have one! I'm not stupid either, thank you.
Certainly, there are mistakes, that's normal, that's why I'm here, but all the information had already been given...
When I say all web pages, I mean all. Any site.
I don't use it for anything, I don't know it, I'm asking for help, so I don't know.
I've never created HTML with PowerShell, I didn't know it was possible and I confess that I'm having a hard time imagining it.
Certainly, there are mistakes, that's normal, that's why I'm here, but all the information had already been given...
When I say all web pages, I mean all. Any site.
I don't use it for anything, I don't know it, I'm asking for help, so I don't know.
I've never created HTML with PowerShell, I didn't know it was possible and I confess that I'm having a hard time imagining it.
So NO, not all web pages retrieve information from your computer... far from it
They can know
The browser / OS used (via Javascript for example)
The PUBLIC IP address (that's on the server side... like in PHP)
And that's it...
no MAC address
No disk sizes
No CPU / RAM consumption ... or any other information of that kind....
An HTML file is nothing more than a text file written in a certain way..
So we can create text files in PowerShell without any problem...
but hey.. look at the link I gave you for HTA.
That might solve your issue.
They can know
The browser / OS used (via Javascript for example)
The PUBLIC IP address (that's on the server side... like in PHP)
And that's it...
no MAC address
No disk sizes
No CPU / RAM consumption ... or any other information of that kind....
I have never created HTML with PowerShell, I didn't know it was possible and I must admit I'm having a hard time imagining it..
An HTML file is nothing more than a text file written in a certain way..
So we can create text files in PowerShell without any problem...
but hey.. look at the link I gave you for HTA.
That might solve your issue.
By any chance... try turning to hta files
https://social.technet.microsoft.com/wiki/contents/articles/2166.how-to-add-a-graphical-user-interface-to-a-powershell-script-by-using-html-applications.aspx
--
Best regards,
Jordane
https://social.technet.microsoft.com/wiki/contents/articles/2166.how-to-add-a-graphical-user-interface-to-a-powershell-script-by-using-html-applications.aspx
--
Best regards,
Jordane
However, I tested it and nothing comes out, let me explain: in my HTML, I integrated "name" instead of the "____"
Then in a PowerShell script, I made the following line: cat web.html | %{$_ -replace "Nom",$nommachine} > web.html
(I don't have infos.html because I don't see what to put in it.. so I put back my base html which is web.html) and then once I launch the page, it shows "Nom" and nothing else...
And also, when I run the PowerShell script, it does nothing and doesn't display any name.
Okay, let's assume you have a file that contains this:
and a Powershell script in the same directory containing this:
$machineName = 'Allybrbs' cat template-infos.html | %{$_ -replace "zzzMACHINE NAMEzzz",$machineName} > infos.htmlRunning the Powershell script should produce a file in the same directory containing:
You will thus have two files. One file containing your intact template and a file which is the separate file produced from the first containing the hard-coded information.
I give you an example, with names taken as examples, and a predetermined machine name, it's up to you to adapt it to your code.
Several remarks:
%{$_ -replace "zzzMACHINE NAMEzzz",$machineName}searches all occurrences of and replaces them with the content of the variable - the search is case-sensitive ("name" is different from "Name"), since you are replacing all occurrences, it is necessary to use a marker consisting of a string that will not be used accidentally elsewhereYou can see the code in action on this Try It Online simulating reading the file with an echo and without the file writing part (the result is just in output, given the limitations of the online interpreter).
I am not a Powershell expert and there are undoubtedly different and more orthodox ways that take advantage of its possibilities (there I mixed commands accessible in classic batch with Powershell). Comments from other contributors are welcome.
Additionally, being on Linux, my means of testing my own suggestions are limited :-)
Good luck with your project!
You should take an interest in the link provided by jordane45 if you want to link HTML in .hta file format to the execution of Powershell.
I'm not familiar with these Microsoft technologies, but this article explains how to do this using VBScript code. You should probably dig deeper into the issue, as this could allow you to create a real dynamic page, the displayed content of which would change if the machine's characteristics have changed.
jordane45's link: https://social.technet.microsoft.com/wiki/contents/articles/2166.how-to-add-a-graphical-user-interface-to-a-powershell-script-by-using-html-applications.aspx
That's exactly the point... On each PC, the information is different (logical), so the file needs to change as well. If your technique doesn't change it, unfortunately, it won't help me...
Yes, I'm already working on Jordane's link.
Thanks again for your idea, which I will keep on hand because it's very good! :)