by yooakim at 2012-08-18 10:06:41
I have searched the net but not been able to find anything. What I am looking for is to use PowerShell as a page handler for IIS. Wouldn't it be nice if one could write server code that emits it's output via IIS to the client?
Anyone know if this can/have been done?
by JasonHelmick at 2012-08-18 11:09:41
I noticed your post regarding IIS and wanted to see if I could help. I'm more of an Admin than a dev, but have you looked at this?
http://devinfra-us.blogspot.com/2011/02 ... art-1.html
I would be interested in Doug's perspective on this, but I think this might help you.
Have a great day!
The Inadvertent IIS Admin,
Stop by the PowerShell and IIS forums!
by yooakim at 2012-08-18 12:40:41
Thanks for the link, interesting but not entirely what I was thinking of. My intention is to let the IIS server be able to simply execute URLs with the PS1 extension, without ASP.NET! Iderally one should be able to do:
And what would happen is that the get-iisstatus.ps1 would be executed on the IIS server and the output sent back to the webbrowser. Hmm... somone ought to have done that? Or else it's time to do it! 😉
by DougFinke at 2012-08-18 13:34:06
Thanks for the reply Jason. I was going to post that link and similar ones.
Thanks for the clarification Joakim, it helps us dial in on the question.
I need to dig a bit deeper, I've seen some http handlers written.
Here are some links we can have some discussion about. I played with this when the Windows Developer Preview became available. The Management OData IIS Extension requires work to set things up and looks promising.
[*]Needs Windows Server 2012 Management ODATA Web Services Dev. Tools
The Management OData IIS Extension is a piece of infrastructure to create an ASP.NET web service OData endpoint. An endpoint built on top of Management OData IIS extension, allows teams to expose access to management capabilities, currently realized through Powershell cmdlets and scripts. It does that by processing OData requests and converting them into PowerShell cmdlet invocation[/*]
[*]I wrote this up PowerShell vNext â€“ Web Service Entities[/*]
[*] Adam Driscoll posted this Management OData and PowerShell[/*]
[*] A CodePlex project that implements an http handler. I haven't tried this but could be a good launch point[/*][/list]
by DonJ at 2012-08-20 07:08:21
Generally speaking, I'm not certain you'd WANT to execute a .PS1 directly like that... I can definitely think of a few downsides.
but, doing so would require a custom host to be built (since it'd need to know to send output to the Response HTTP stream, amongst other specializations). That said, embedding PowerShell code within a normal C# or VB ASP.NET page is easy-peasy. That's definitely how Microsoft envisioned people incorporating PowerShell commands into a Web page.
by yooakim at 2012-09-07 23:30:18
Actually, after a bit of more research I found that there is an implementation of a custom IHttpHandler mapped to *.ps1x files that executes PS1 files, case closed!
I haven't had time to test this but it certainly looks like what I wanted.
by JasonHelmick at 2012-09-08 09:21:23
Awesome! Nice catch! I'm going to sit down and try it out myself...let us know how results turn out!
by DonJ at 2012-09-08 09:32:06
That would definitely be easier for admins than embedding PowerShell in an ASP.NET page, so I'm curious to see what you guys come up with.