Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module ActiveDirectory
- $Csvpath = "C:\we.csv"
- $AccountExpires = (Get-Date).AddDays(+365)
- $Users = Import-CSV -Path $Csvpath -Delimiter ";"
- $CurrDomain = Get-ADForest | Select-Object -ExpandProperty name
- ForEach($User in $Users){
- $UserParams =@{
- GivenName = $User.FN
- SurName = $User.LN
- Displayname = $User.FN + " " + $User.LN
- Name = $User.FN + " " + $User.LN
- SamAccountName = $User.UN
- UserPrincipalName = $User.FN + "." + $User.LN + "@" + $CurrDomain
- Description = $User.Desc
- AccountPassword = $User.PW | ConvertTo-SecureString -AsPlainText -Force
- $Mail = $User.Mail
- Enabled = $True
- }
- New-ADUser @UserParams
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement