PowerShell Server V6 - Online Help
PowerShell Server V6
Questions / Feedback?

PowerShell Panel for ASP.NET

PowerShell Panel is an ASP.NET control that provides a way to render PowerShell ASP templates directly as part of a regular ASP.NET WebForm application. PowerShell ASP is an ASP-like template language that contain a mixture of markup (HTML, XML or whatever you want to generate) and inline PowerShell code.

Installing PowerShell Panel

To add the PowerShell Panel to your Visual Studio toolbox follow these easy steps:

  1. Right click on the toolbox and create a new tab with the title "PowerShell Panel".
  2. Drag the "PowerShellASP.dll" from the bin directory of the installation onto the new tab.
That's it! You can now drag and drop the PowerShell Panel component onto your pages.

Using PowerShell Panel

To use PowerShellPanel all you need to do is follow these simple steps:

  1. Create a new ASP.NET Web Site/Application or open an existing one in Visual Studio.
  2. Add a reference to the nsoftware.PowerShellASP.dll assembly, or copy it to your web site's ./bin folder
  3. In the ASP.NET page or control you want to use PowerShell Panel, register the control:
    <%@ Register Assembly="nsoftware.PowerShellASP"
    TagPrefix="cc1" %>
  4. Add the PowerShell Panel control and simply write your PowerShell ASP script directly into the panel:
    <cc1:PowerShellPanel ID="PSPanel2" runat="server">
       <asp:Label ID='Label2' ForeColor="Red" runat="server" Text="&lt;%= $request.PhysicalApplicationPath %&gt;" />
       &lt;% ls 'c:\' | %{ %&gt;
          <li>&lt;%= $_.Name %&gt;</li>
       &lt;% } %&gt;

Using Alternate Syntax

Sometimes you might want to avoid having to do so much escaping of HTML when writing your PowerShell ASP scripts in PowerShellPanel controls, particularly of < and > characters. To facilitate this, you can set the UseAlternateDelimiters property of the PowerShellPanel control to true.

After doing this,PowerShellPanel will use the [% and %] sequences as delimiters for code blocks instead of the <% and %> delimiters normally used. With this, the example above could be written like this instead:

<cc1:PowerShellPanel ID="PSPanel1" runat="server" 
   <asp:Label ID='Label1' ForeColor="Red" runat="server" 
              Text="[%= $request.PhysicalApplicationPath %]" />
   [% ls 'c:\' | %{ %]
      <li>[%= $_.Name %]</li>
   [% } %]

Note: By default no profiles are loaded when executing. However you can use dot-sourcing to load any profile. For example:


Copyright (c) 2017 /n software inc. - All rights reserved.
Build 6.0.6240.0