Creating a Real Looking user accounts in Active Directory Labs

To do this I first go to the Fake Name Generator page and select from the menu the Order in Bulk option, click on the checkbox to accept the terms of services and select as output Comma separated (.csv)

Now on step 3, I can select the name set and the country for the account information I want. Once that is selected I then select the following fields:

GivenName

Surname

StreetAddress

City

Title

Username

Password

Country

TelephoneNumber

Occupation

Once the fields have been selected I simply specify the number, the email and enter the captcha to get the accounts via email.

Now once I have the CSV in my experience they tend to have repeated usernames, also I have found my self-missing one or more of the fields when I selected what to include in the CSV so I wrote a series of PowerShell functions I can use when working with the data.

The first function is a simple one that allows me to test that the CSV contains all the fields I want. It simply extracts the header from the CSV and checks against a list.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

<#

.Synopsis

TestaCSV from FakeNameGenerator.com forrequired fields.

.DESCRIPTION

TestaCSV from FakeNameGenerator.com forrequired fields.

.EXAMPLE

Test-LabADUserList-Path.\FakeNameGenerator.com_b58aa6a5.csv

#>

functionTest-LabADUserList

{

[CmdletBinding()]

[OutputType([Bool])]

Param

(

[Parameter(Mandatory=$true,

Position=0,

ValueFromPipeline=$true,

ValueFromPipelineByPropertyName=$true,

HelpMessage="Path to CSV generated from fakenamegenerator.com.")]

[Alias("PSPath")]

[ValidateNotNullOrEmpty()]

[string]

$Path

)

Begin{}

Process

{

# Test if the file exists.

if(Test-Path-Path$Path-PathType Leaf)

{

Write-Verbose-Message"Testing file $($Path)"

}

else

{

Write-Error-Message"File $($Path) was not found or not a file."

$false

return

}

# Get CSV header info.

$fileinfo=Import-Csv-Path$Path|Get-Member|Select-Object-ExpandProperty Name

$valid=$true

if('City'-notin$fileinfo){

Write-Warning-Message'City field is missing'

$valid=$false

}

if('Country'-notin$fileinfo){

Write-Warning-Message'Country field is missing'

$valid=$false

}

if('GivenName'-notin$fileinfo){

Write-Warning-Message'GivenName field is missing'

$valid=$false

}

if('Occupation'-notin$fileinfo){

Write-Warning-Message'Occupation field is missing'

$valid=$false

}

if('Password'-notin$fileinfo){

Write-Warning-Message'Password field is missing'

$valid=$false

}

if('StreetAddress'-notin$fileinfo){

Write-Warning-Message'StreetAddress field is missing'

$valid=$false

}

if('Surname'-notin$fileinfo){

Write-Warning-Message'Surname field is missing'

$valid=$false

}

if('TelephoneNumber'-notin$fileinfo){

Write-Warning-Message'TelephoneNumber field is missing'

$valid=$false

}

if('Username'-notin$fileinfo){

Write-Warning-Message'Username field is missing'

$valid=$false

}

$valid

}

End{}

}

The next function will remove any duplicate username entries, I have found with large samples that it is inevitable for some of the usernames to be duplicated. This function uses a lot the pipeline so as minimize memory use, not the fastest but when dealing with several thousands of fake user details in a VM environment with limited memory it becomes an acceptable tradeoff.

The last function does the importing of accounts from the processed CSV with duplicate usernames removed into a specified OU. The function will create OUs under the specified one for each country in the account set.

Now the functions will be available for you to use in the interactive session. We start by testing the file we got via email to make sure it has all the fields we want and that no mistakes were done when ordering the names:

Once it finishes you should now have a nice set of test accounts in AD for you to use.

Of the 3,000 accounts, only 2,182 where unique when it came to username, still a very good number for testing. In the future, I will probably make it so when it finds accounts with repeated usernames, Surnames or LastNames to add a random string to each.