Is there somewhere that you're learning all this? I see you're using ADSI. Is
there a tutorial you could point me to regarding this? I'm particularly
interested in understanding this piece:
$objRoot = [ADSI]"WinNT://./Administrator,user";
$objGrpMembers = @($objRoot.psbase.Invoke("Groups"));
$objGrpMembers |
%{$SessionProxy.ResultListBox.Items.Add($_.GetType().InvokeMember("Name",
'GetProperty', $null, $_, $null))}
what does WinNT://./Administrator,user mean?
Is that the username/pwd combo to use?
So far no matter who I put into the textbox the group returned is
"Administrators" Is this checking local groups? I need it to check Active
Directory groups.
Plus will this cycle through the groups.
Last question for now :-)
--- Do you have any reason to prefer writing ADSI scripts versus WMI scripts?
Thanks again for being such a huge help!
--
Regards,
Blake Whitney
GC Email Manager
"fixitchris" wrote:
> Try this updated default.aspx code.... This should give you a clearer idea of
> what is happening.
>
> <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
> Inherits="_Default" %>
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head id="Head1" runat="server">
> <title>PowerAsp Demo Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <h3>PowerShell ASP Test!</h3>
> <p>
> <asp:Label ID="DateLabel" runat="server" Text="Todays
> date"></asp:Label>
> </p>
> <asp:TextBox ID="Expression" Width="500" runat="server" Rows="3"
> TextMode="MultiLine">
> Administrator
> </asp:TextBox>
> <p>
> <asp:Button ID="Button1" OnClick="Evaluate" runat="server" Text="Eval
> Expression" Visible="true" />
> <asp:Button ID="Button2" OnClick="Clear" runat="server" Text="Clear
> Listbox " Visible="true" />
> </p>
> <asp:TextBox ID="Script" visible="false" runat="server">
> $objRoot = [ADSI]"WinNT://./Administrator,user";
> $objGrpMembers = @($objRoot.psbase.Invoke("Groups"));
> $objGrpMembers
> |%{$SessionProxy.ResultListBox.Items.Add($_.GetType().InvokeMember("Name",
> 'GetProperty', $null, $_, $null))}
> </asp:TextBox>
> <p>
> <asp:ListBox ID="ResultListBox" Width="600" runat="server"
> Rows="12"></asp:ListBox>
> </p>
> <script runat="server" language="VB">
> Sub Evaluate(ByVal s As Object, ByVal e As EventArgs)
> If Me.Session("runspace") Is Nothing Then
> MyRunspace =
> System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace()
> MyRunspace.Open()
> Me.Session.Add("runspace", MyRunspace)
> Me.SessionProxy =
> System.Collections.Hashtable.Synchronized(New Hashtable())
> MyRunspace.SessionStateProxy.SetVariable("SessionProxy",
> Me.SessionProxy)
> Me.Session.Add("SessionProxy", SessionProxy)
> Else
> SessionProxy = Me.Session("SessionProxy")
> MyRunspace = Me.Session("runspace")
> End If
> sessionproxy("DateLabel") = DateLabel
> SessionProxy("Expression") = Expression
> SessionProxy("ResultListBox") = ResultListBox
> myinvoke = New
> System.Management.Automation.RunspaceInvoke(MyRunspace)
> MyInvoke.Invoke(Script.Text)
> End Sub
> Sub Clear(ByVal s As Object, ByVal e As EventArgs)
> ResultListBox.Items.Clear()
> End Sub
> </script>
> </div>
> </form>
> </body>
> </html>
>
>
> >
> > One other side question if you don't mind:
> >
> > If I want this asp.net page to run on windows 2003 server, do i need to
> > install .net 3.0 or 2.0 as well as powershell? I tried to install powershell
> > (x86 version) and it said that it was not the right OS type or something. Odd.
>
> To serve out ASP.NET Powershelled pages on 2003 server you need:
> IIS6
> .NET 2 or 3 (see aspnet_regiis.exe command)
> Powershell
>
> Are you installing x86 Powershell on 64 bit 2003 server? I believe 64 bit
> Powershell came out...?