ASP.NET Weblogs

Welcome to ASP.NET Weblogs Sign in | Join | Help
in Search

The Technical Adventures of Adam Weigert

February 2010 - Posts

  • Overriding Inheritance for IIS 6.0 Virtual Directories

    If you have an IIS site that has a mixture of ASP.NET 1.1 and 2.0 virtual directories below it, changing the root site ASP.NET settings could affect the virtual directory ASP.NET settings as well since IIS inherits except for explicit overrides. This little PowerShell script will take each setting and persist it to the virtual directory so you are able to freely change the root site settings without affecting the applications below it.

    Please remember to backup your IIS settings before you do this, just incase it has adverse affects on your IIS server.

    function Persist-IIsSettings ( $obj ) {
        Write-Host $obj.Path
       
        $obj.Properties.GetEnumerator() |% {
            $propertyName = $_.PropertyName
            $value        = $obj.Get($propertyName)
           
            if ( -not ($value -is [System.__ComObject]) ) {
                $obj.Put($propertyName, $value)
            }
        }
       
        $obj.SetInfo()

        $obj.Children |% { Persist-IIsSettings $_ }
    }

    Persist-IIsSettings ([ADSI]"IIS://localhost/W3SVC/1/ROOT")

  • ASP.NET PowerShell Data Source Control

    Extending on the small proof-of-concept I mentioned yesterday I created this simple data source control that lets you bind a Repeater or DataGrid to it like an ObjectDataSource control but it executes a PowerShell script to retrieve the results.

    <asp:PowerShellDataSource ID="EmployeesDataSource" runat="server">
        [PSObject]"" | Add-Member NoteProperty "Title" "Software Engineer" -passThru | Add-Member NoteProperty "Name" "Mike Wolford" -passThru
        [PSObject]"" | Add-Member NoteProperty "Title" "Software Evangelist" -passThru | Add-Member NoteProperty "Name" "Scott Root" -passThru
    </asp:PowerShellDataSource>



    <asp:Repeater runat="server" DataSourceID="EmployeesDataSource">
        <ItemTemplate>
            <h4><%# DataBinder.Eval(Container.DataItem, "Title") %>: <%# DataBinder.Eval(Container.DataItem, "Name") %></h4>
        </ItemTemplate>
    </asp:Repeater>

    If this is something that interests you, take a look over  at http://aspower.codeplex.com/

  • ASP.NET PowerShell Runspace Control

    This is just a little concept project I am working on so I can run PowerShell scripts within my ASP.NET applications. As I am a server administrator, I love PowerShell + WMI, and bringing this power into ASP.NET my automation capabilities are being greatly simplified. I'll build on this solution as I play around with actually implementing this as a primary source of automation from support a Windows Server environment.

    I am aware of other projects/products that allow you to do similar things, I just needed something simple, and I don't want to code an entire page in PowerShell, just specific tasks.

     http://aspower.codeplex.com/

More Posts