-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.ps1
23 lines (22 loc) · 1.49 KB
/
Setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#sets the two new properties Age and Sex
[xml]$global:config = Get-Content .\App.config
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Import-Module -name "$scriptDir\Modules\SPIntegration.psm1" -Force #-ErrorAction SilentlyContinue -DisableNameChecking
New-UserProfileProperty -Propertyname "T-Age" -Propertydisplayname "Age" -Description "User Age"
New-UserProfileProperty -Propertyname "T-Sex" -Propertydisplayname "Sex" -Description "M for Male, F for Female"
function New-Users {
$DomainController = $env:COMPUTERNAME
$Users = Import-Csv -Delimiter ";" -Path ".Misc\UserList-sn.csv" -Encoding Default
foreach ($User in $Users)
{
$Displayname = $User.Firstname + " " + $User.Lastname
$UserFirstname = $User.Firstname
$UserLastname = $User.Lastname
$OU = $User.OU
$SAM = $User.SAM
$UPN = $User.Firstname + "." + $User.Lastname + "@" + $User.Maildomain
$Description = $User.Description
$Password = $User.Password
New-ADUser -Name "$Displayname" -DisplayName "$Displayname" -SamAccountName $SAM -UserPrincipalName $UPN -GivenName "$UserFirstname" -Surname "$UserLastname" -Description "$Description" -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -Path "$OU" -ChangePasswordAtLogon $false –PasswordNeverExpires $true -server $DomainController
}
}