Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Execute PowerShell Scripts via http url requests

1,077 views
Skip to first unread message

michae...@gmail.com

unread,
May 31, 2007, 10:12:37 PM5/31/07
to
Is there a way to execute PowerShells commands/scripts via http url
requests?

An example would be something like: http://127.0.0.1:8080/ps?command=$pshome
which would return: C:\WINDOWS\system32\WindowsPowerShell\v1.0

Thanks!

Brandon Shell

unread,
May 31, 2007, 11:23:45 PM5/31/07
to
You could do this, but it would be processed server side and would require
asp or aspx. I suppose you could even do it as an ISAPI filter.

Why would you want to do this? Or more specifically... what is your goal.

<michae...@gmail.com> wrote in message
news:1180663957....@q66g2000hsg.googlegroups.com...

michae...@gmail.com

unread,
Jun 1, 2007, 5:57:52 AM6/1/07
to
On May 31, 11:23 pm, "Brandon Shell" <tshell.m...@mk.gmail.com> wrote:
> You could do this, but it would be processed server side and would require
> asp or aspx. I suppose you could even do it as an ISAPI filter.
>
> Why would you want to do this? Or more specifically... what is your goal.
>
> <michael.t...@gmail.com> wrote in message

>
> news:1180663957....@q66g2000hsg.googlegroups.com...
>
> > Is there a way to execute PowerShells commands/scripts via http url
> > requests?
>
> > An example would be something like:
> >http://127.0.0.1:8080/ps?command=$pshome
> > which would return: C:\WINDOWS\system32\WindowsPowerShell\v1.0
>
> > Thanks!

The goal is utimately to remotely execute a PowerShell scripts from a
simple url request rather than a just an API. In the past, this was
not safe because of security issues. However, because PowerShell has
a security layer built-in, it would now be of great use. Imagine
writing a signed PowerShell script which could return data from a
legacy system. This would be a very powerful and flexiable tool.

RichS

unread,
Jun 1, 2007, 7:08:01 AM6/1/07
to
What sort of information are you looking to return. WMI can be used to
access remote machines from within PowerShell
--
Richard Siddaway
Please note that all scripts are supplied "as is" and with no warranty
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk

Brandon Shell

unread,
Jun 1, 2007, 9:36:06 AM6/1/07
to
I agree with Rich on this.. WMI will most likely provide you with everything
you need.

That said, if your goal is to collect data from all the "clients" via a
webpage then you will have to have powershell installed on all of them. If
that is indeed your intention actually you do not have to write server side
code... you could write a client side vb/jscript to call powershell with the
script as parameter and post the results.

p.s. I want to clarify.. I think WMI is your best bet, but wanted to give
the info you asked for.

"RichS" <Ri...@discussions.microsoft.com> wrote in message
news:B979A5A2-75A6-4795...@microsoft.com...

William Stacey [C# MVP]

unread,
Jun 1, 2007, 10:25:41 AM6/1/07
to
You could do with wcf on server side in http w/ REST for get/put behavior.
Have not played with it, but should work. As others said, asp server page
should work also.

--
William Stacey [C# MVP]
PowerLocker, PowerPad
www.powerlocker.com

<michae...@gmail.com> wrote in message
news:1180663957....@q66g2000hsg.googlegroups.com...

John Vottero

unread,
Jun 1, 2007, 11:52:56 AM6/1/07
to

<michae...@gmail.com> wrote in message
news:1180691872.7...@p77g2000hsh.googlegroups.com...

I think this would be great, a really simple way to expose information.
There has to be some way to put the ConvertTo-Html cmdlet to good use.

If I was going to do it, I think I would look at writing a Web Service
Extension. It would also be interesting to look into creating an ASP.NET
control that executes a PowerShell script so you could drop the output of a
script into an ASP.NET page.

Marco Shaw

unread,
Jun 1, 2007, 2:43:25 PM6/1/07
to

Joris van Lier

unread,
Jun 2, 2007, 11:57:06 AM6/2/07
to
<michae...@gmail.com> wrote in message news:1180663957....@q66g2000hsg.googlegroups.com...

I've blogged about 2 methods
Method 1 creates an actual HTTP Listener so powershell scripts can be executed from remote computers

HTTPowerShell
http://whizzrd.spaces.live.com/blog/cns!36AFCF1E860E662E!166.entry

Method 2 creates a custom protocol prefix and allows you to invoke powershell commands via url's on the local computer only

PowerShell URL Protocol
http://whizzrd.spaces.live.com/blog/cns!36AFCF1E860E662E!171.entry


--
Joris van Lier
Please note that all code and opinions are supplied "as is" and with no warranty
Blog: http://whizzrd.spaces.live.com

michae...@gmail.com

unread,
Jun 5, 2007, 6:50:19 AM6/5/07
to
On Jun 2, 11:57 am, "Joris van Lier" <whiz...@hotmail.com> wrote:
> <michael.t...@gmail.com> wrote in messagenews:1180663957....@q66g2000hsg.googlegroups.com...

> > Is there a way to execute PowerShells commands/scripts via http url
> > requests?
>
> > An example would be something like:http://127.0.0.1:8080/ps?command=$pshome
> > which would return: C:\WINDOWS\system32\WindowsPowerShell\v1.0
>
> > Thanks!
>
> I've blogged about 2 methods
> Method 1 creates an actual HTTP Listener so powershell scripts can be executed from remote computers
>
> HTTPowerShellhttp://whizzrd.spaces.live.com/blog/cns!36AFCF1E860E662E!166.entry

>
> Method 2 creates a custom protocol prefix and allows you to invoke powershell commands via url's on the local computer only
>
> PowerShell URL Protocolhttp://whizzrd.spaces.live.com/blog/cns!36AFCF1E860E662E!171.entry
>

Joris,

> --
> Joris van Lier
> Please note that all code and opinions are supplied "as is" and with no warranty
> Blog:http://whizzrd.spaces.live.com


Method 1 is exactly what I am looking for!

Now I would like to output the response in XML format in the browser
(but not save to file).

Since I am new to PowerShell, I have some research to do.

Thanks,

0 new messages