im going to design a simple html web form for people to enter there username/old password/new password in a text box and when they click the submit button i want to pass it to powershell Set-ADAccountPassword so it changes there passwords
What have you tried? Have you done any research prior to posting?
Take a look at PowerShell endpoints and/or JEA. A quick google search you’d also find ‘WebJea’ which is a module doing exactly what you described. There’s also paid products out there that make it simple like PowerShell Universal.
In the future, please put forth a little bit of effort before you post. We’re generally very happy to assist, but we also do expect people to try and do a little research prior to posting.
I have looked at my previous post and someone suggested MS does this already
but i want to learn html/css so i thought i could do it myself
in the last post you mentioned powershell runspaces, is that JEA?
I have looked at powershell universal but i thought it would be better to learn html/css rather than PSU as i can put it to more use later on in my career
HTML/CSS is front end and has little to do with PowerShell/JEA. The idea is using them together to accomplish your task.
Your original question is asking about a web form that basically can be used to call PowerShell commands upon submission. It’s possible, you’ll have to put in some work to do it, and if you plan on doing it all yourself, you aren’t going to get the job done just using HTML/CSS. Don’t think your post you sharing about what MS ‘does’ already is exactly at play here, since you say you want to it yourself. WebForms + JEA You can run any PS code you want and call it from a webform if you build it, which is what you’re asking. JEA is a tool to get that done.
I know it’s possible because my work uses it a TON. I have a web developer that creates websites and creates ‘connectors’ in C# to run PowerShell code on a back-end PowerShell Endpoint. This basically involves using PowerShell JEA (Just Enough Administration).
You’ll notice in your previous post, I also posted, and suggested to look up JEA.
So I highly encourage you to play around with JEA There’s very likely some other options out there, I just haven’t googled around to see all the options. Tools like PowerShell Universal just make the whole process easy. You probably can still manipulate HTML/CSS using PowerShell Universal. You should take a look and do some googling to see what fits your needs.
Lastly, you ned to post about all your requirements up front. Using a webform to run PS, is not the same as ‘I want to learn HTML/CSS’. If that’s part of your requirement, you should state that up front so folks have more information to assist. Otherwise,someone might suggest a MS Form that connects via like something in power automate that runs Powershell or something similar. There’s too many ways to accomplish tasks, the more information you provide, the better assistance you will get.
PowerShell Universal is a tool to accomplish tasks, not a language. You can do both. While I haven’t used PowerShell Universal, I’m fairly certain it’s pretty customizable and one way you’d customize the ‘look’ of the webform is probably is through HTML/CSS. However, in this context you should consider the HTML/CSS more or less, how the web form is going to look, as there’s not going to be any solid way for you to interact with a PowerShell session (backend) with HTML/CSS alone. If you wish to know if your specific use case is possible with the software, please reach out to Ironman Software.
Nonetheless, you don’t have to use PowerShell Universal, it’s just a tool to makes accomplishing a task, such as the one you presented, easier. You can learn HTML/CSS, and spin up your own web front end. Just know that if you are doing that you are going to have an additional step of learning how to connect from that web front end to a PowerShell backend. As previously suggested, one way to accomplish this is C#, which is well outside the scope of this forum. You can search around for PowerShell Session in C#, you should get hits on how to create runspaces with sample code. There’re very likely other ways as well, but HTML/CSS alone won’t be possible.
hi @dotnVo yes i do know powershell universal is an all in one tool to use to do this easy/quickly ie make the web front end and that would pass the variables to powershell ie the backend
but i would rather do this the old fashioned way ie use HTML/CSS for the front end and what tool would you use to talk to powershell ie the backend, you say C#, what is JEA then?
What I did (some time back a few years ago) was start with the resource from the link you provided as that takes care of the back end and no need for PowerShell or any additional tools (let M$ do all the heavy lifting for you), then I customized the HTML and CSS to my liking. You might give that a wack.
You can use HTML/CSS but HTML/CSS can’t run PS code on its own as I’ve stated a few times (as far as I’m aware anyway), which is why i mentioned C#. This is also why people are suggesting you use tools that are already out there, (like the MS provided one), as people-built tooling to allow building of solutions for this kind of situation. Like the MS provided web form, JEA is another tool provided by MS.
(Note: this stuff was all pretty easily searchable using terms like ‘powershell AND jea’, ‘webjea’, and ‘powershell C# runspace’)
If you aren’t super comfortable in .NET or have some skills programming, my concern is that C# is going to be a bit of a barrier to entry. That’s where @tonyd 's suggestion comes into play, and you can simply use the MS part, and not worry about the PS. then you just modify HTML/CSS (which you’re still learning when you do that. However, we won’t be able to answer any HTML/CSS questions you have, we’re a PowerShell shop You just need to figure out what you’re trying to focus your efforts on and go from there.
Before I found that the only other thing that came to mind is to have the script actually launch the web page in the browser have your HTML code write something to a text file or something that PowerShell can pick up after the fact. Then have PowerShell monitor for the browser process to end, that could trigger it to pick up the text file and execute based upon its contents.
If I knew HTML a little better there may even be a way for the mouse click to trigger the browser to close, btu I’m sure that triggers all kinds of security features.
As I type that a quick search turned up this HTML code. <button onclick="closeWindow()">Close Window</button>