i'm trying to print all users of a group "Students" to a Textfile "Students.txt".
I'm not in a domain, so this does not work:
net group "Students" >> students.txt
because i get following:
This command can be used only on a Windows Domain Controller.
Thank you in advance
If anybody is interested in a VB.Net solution, i've programmed a Winform solution with a multiline Textbox to copy/paste the members (anyway, thanks for your help):
Imports System.DirectoryServices 'first add a refernce to it from .Net Tab'
....
Public Function MembersOfGroup(ByVal GroupName As String) As List(Of DirectoryServices.DirectoryEntry)
Dim members As New List(Of DirectoryServices.DirectoryEntry)
Try
Using search As New DirectoryServices.DirectoryEntry("WinNT://./" & GroupName & ",group")
For Each member As Object In DirectCast(search.Invoke("Members"), IEnumerable)
Dim memberEntry As New DirectoryEntry(member)
members.Add(memberEntry)
Next
End Using
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Return members
End Function
Private Sub TxtGroup_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TxtGroup.KeyDown
If e.KeyCode = Keys.Enter Then
Me.TxtGroupMembers.Text = String.Empty
If Me.TxtGroup.Text.Length <> 0 Then
Dim members As List(Of DirectoryServices.DirectoryEntry) = MembersOfGroup(Me.TxtGroup.Text)
For Each member As DirectoryServices.DirectoryEntry In members
Me.TxtGroupMembers.Text &= member.Name & vbCrLf
Next
End If
End If
End Sub