Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Execute PowerShell Scripts via http url requests

Reply
 
Old 05-31-2007   #1 (permalink)
michael.teti@gmail.com


 
 

Execute PowerShell Scripts via http url requests

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!


My System SpecsSystem Spec
Old 05-31-2007   #2 (permalink)
Brandon Shell


 
 

Re: Execute PowerShell Scripts via http url requests

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.teti@gmail.com> wrote in message
news:1180663957.054670.51570@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!
>


My System SpecsSystem Spec
Old 06-01-2007   #3 (permalink)
michael.teti@gmail.com


 
 

Re: Execute PowerShell Scripts via http url requests

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.054670.51570@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.

My System SpecsSystem Spec
Old 06-01-2007   #4 (permalink)
RichS


 
 

Re: Execute PowerShell Scripts via http url requests

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


"michael.teti@gmail.com" wrote:

> 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.054670.51570@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.
>
>

My System SpecsSystem Spec
Old 06-01-2007   #5 (permalink)
Brandon Shell


 
 

Re: Execute PowerShell Scripts via http url requests

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" <RichS@discussions.microsoft.com> wrote in message
news:B979A5A2-75A6-4795-8943-251ECF56426B@microsoft.com...
> 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
>
>
> "michael.teti@gmail.com" wrote:
>
>> 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.054670.51570@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.
>>
>>


My System SpecsSystem Spec
Old 06-01-2007   #6 (permalink)
William Stacey [C# MVP]


 
 

Re: Execute PowerShell Scripts via http url requests

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



<michael.teti@gmail.com> wrote in message
news:1180663957.054670.51570@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!
|


My System SpecsSystem Spec
Old 06-01-2007   #7 (permalink)
John Vottero


 
 

Re: Execute PowerShell Scripts via http url requests


<michael.teti@gmail.com> wrote in message
news:1180691872.717109.103210@p77g2000hsh.googlegroups.com...
> 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.054670.51570@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.
>


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.


My System SpecsSystem Spec
Old 06-01-2007   #8 (permalink)
Marco Shaw


 
 

Re: Execute PowerShell Scripts via http url requests

michael.teti@gmail.com wrote:
> 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!
>


http://ps1.soapyfrog.com/2007/01/24/...in-powershell/

Marco
My System SpecsSystem Spec
Old 06-02-2007   #9 (permalink)
Joris van Lier


 
 

Re: Execute PowerShell Scripts via http url requests

<michael.teti@gmail.com> wrote in message news:1180663957.054670.51570@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

HTTPowerShell
http://whizzrd.spaces.live.com/blog/...662E!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/...662E!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

My System SpecsSystem Spec
Old 06-05-2007   #10 (permalink)
michael.teti@gmail.com


 
 

Re: Execute PowerShell Scripts via http url requests

On Jun 2, 11:57 am, "Joris van Lier" <whiz...@hotmail.com> wrote:
> <michael.t...@gmail.com> wrote in messagenews:1180663957.054670.51570@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,

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
In Powershell execute scripts on many remote machines ,Monitor and report back General Discussion
Execute scripts in current scope? PowerShell
How to execute (perl) scripts in Powershell without DOS box PowerShell
Right-click execute scripts ? PowerShell
AD LogOn Scripts Execute permissions Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46