I wonder if it is possible to execute a powershell script and show the
result in a the page from a IIS website (6.0 on a W2003 R2 Ent SP2).
Thanks for your help.
--
P.J.A.
These links should help:
http://www.powershelltoys.com/
3 part series:
http://devinfra-us.blogspot.com/2008/05/powershell-and-aspnet-part-3.html
There are even more options...
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
PowerShellASP (http://powershelltoys.com/) might be the right thing
for you.
What is PowerShell ASP?
"PowerShellASP is an ASP-like template language for Web Applications;
templates contain a mixture of markup (HTML, XML or whatever you want
to generate) and inline PowerShell code. At runtime, templates/pages
are fully translated to PowerShell code and executed as a single unit
inside a PowerShell pipeline, with the results sent to the client
browser.
PowerShellASP runs off the ASP.NET platform, implemented as a custom
IHttpHandler mapped to *.ps1x files. Because of this, you can mix
PowerShellASP pages alongside any ASP.NET application. This provides a
great way to leverage PowerShellASP inside your existing applications
as needed or you can create complete applications from scratch based
only on *.ps1x pages."
-aleksandar
http://powershellers.blogspot.com
Check out PowershellASP and PoshBoard
http://powershelltoys.com/
http://www.codeplex.com/Poshboard
Also, we talk about this subject on Episode 34, and in Episode 36, we interview
a guy from /n software, the guys who created PowersShellASP.
http://powerscripting.wordpress.com/?s=powershellasp
--
Author, Tech Prosaic blog (http://halr9000.com)
Webmaster, Psi (http://psi-im.org)
Community Director, PowerShellCommunity.org
Co-host, PowerScripting Podcast (http://powerscripting.net)
Regards,
--
P.J.A.
I'll try to help you out... I'm assuming you're trying to use this *on*
an Exchange server? Just so we don't have to go through the
requirements of installing the Exchange cmdlets remotely...
get-mailboxfolderstatistics "mailboxname" | ft FolderPath, ItemsInFolder,
@{Label="FolderSize(MB)";expression={$_.FolderSize.ToMB()} } -auto
Oh, you may be in for a long battle with user permissions before being
able to actually run the Exchange cmdlets...
Oh, you migth only need to just do something like this in your code:
Add-PsSnapin Microsoft.Exchange.Management.PowerShell.Admin
I was thinking you'd need to do some C#.
I have already created the local profile.ps1 an added Add-PSSnapin
Microsoft.Exchange.Management.PowerShell.Admin which works great for the
local user to lauch PowerShell with the Exchange Snapin loaded. But from my
findings this has to be lauched via this CS file or loaded into memory
somehow. I wish I was more adept to this type of programming.
I have already created the local profile.ps1 an added Add-PSSnapin
Microsoft.Exchange.Management.PowerShell.Admin which works great for the
local user to lauch PowerShell with the Exchange Snapin loaded. But from my
findings this has to be lauched via this CS file or loaded into memory
somehow. I wish I was more adept to this type of programming but I am not
knowledgeable on C# at all.
I know of PoshASP, but haven't tried it yet.
Have you tried simply adding this PowerShell code into your .ps1x page:
Add-PsSnapin Microsoft.Exchange.Management.PowerShell.Admin
I am just starting to rewrite my ASP poages that use C# and powershell to
use powershellASP.
To add the Exchange snappin, do this:
<% add-pssnapin *exchange* %>
The web page will have to run in an application pool that is configured wtih
an account that hads the proper exchange permissions to gather the data that
you weant to return to the user.
Then, try this:
<head>
<style>
body,td,th { font-family: Arial, Helvetica, sans-serif; font-size:
14px; }
h1 { font-size: 26px; color: #0B4982; }
#left { float:left; margin:10px; width:180px; border:1px
solid gainsboro;font-weight:bold}
#left P { border-bottom:1px solid gainsboro;padding:4px;
margin-bottom:2px;margin-top:2px; }
#left UL { margin:2px; padding:0px; }
#left LI { list-style: none; margin:4px; }
</style>
</head>
<body>
<% add-pssnapin *exchange* %>
<% $mailboxname = $request['logon_user'].split("\")[1]%>
<% get-mailboxfolderstatistics $mailboxname | ft FolderPath, ItemsInFolder,
@{Label="FolderSize(MB)";expression={$_.FolderSize.ToMB()} } -auto %>
</body>
You will have toi fornat the results to your liking ;)
My earlier reply was all sorts of ugly
I am just starting to rewrite my ASP poages that use C# and powershell to
use powershellASP.
To add the Exchange snappin, do this:
<% add-pssnapin *exchange* %>
The web page will have to run in an application pool that is configured wtih
an account that hads the proper exchange permissions to gather the data that
you weant to return to the user.
Then, try this:
can you share more details?
I want to do the same
EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng