I have the following Code so the User can enter their domain before the program runs.
The resulting textfile does not output the users..just the word Schema…
EDIT 1: Updated to include all code. I now can run it and it returns a text file that lists
OU=_USERS
OU=_GROUPS
OU=_ETC
ETC ETC
Sub PrintUserNames()
'Declare Command
Dim de As New DirectoryEntry()
'Nameint Place to Write file
Dim userFile As String = "C:\DomainUsers.txt"
Dim fileExists As Boolean = File.Exists(userFile)
'Use Input Box for domain entry
Dim message, Title, defaultValue As String
Dim myValue As Object
message = "Enter your Domain Name"
Title = "Domain Name Entry"
defaultValue = "Enter Domain Name"
myValue = InputBox(message, Title, defaultValue)
'Get List of all users on Domain using WinNT
'Replacement Command
Dim ReplaceCommand1 As String = de.Path.Replace("***", myValue) = "WinNT://""***"""
Using sw As New StreamWriter(File.Open(userFile, FileMode.OpenOrCreate))
For Each d As DirectoryEntry In de.Children()
sw.WriteLine(d.Name)
Next
End Using
Thanks for the tip Filburt.
I just threw out the actually actually making a replacement command and just using it as shown below.