真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

批量創(chuàng)建AD賬號(hào)添加SMTP、Manager、extensionAttribute4屬性

最近公司收購(gòu)新工廠需要大批量創(chuàng)建AD賬號(hào),由于AD的自定義屬性比較多需要添加proxyaddress郵件主SMP地址、直線經(jīng)理Manager屬性、extenstionAttribute4屬性

創(chuàng)新互聯(lián)專(zhuān)注于企業(yè)成都營(yíng)銷(xiāo)網(wǎng)站建設(shè)、網(wǎng)站重做改版、承德網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5場(chǎng)景定制、商城網(wǎng)站開(kāi)發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站建設(shè)、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁(yè)設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性?xún)r(jià)比高,為承德等各大城市提供網(wǎng)站開(kāi)發(fā)制作服務(wù)。

userid UPN Initials Fistname Lastname DisplayName Office telephoneNumber postalcode fax Email StreetAddress City Province country company C mobile Title Department Manager SMTP
astest35ad test35.xx.ad@test.cn xx test35 AD test35 ad 506F test xx xxxx test35.xx.ad@test.cn No. 55, Persiaran Selangor, Seksyen 49 GZ GD China Guangzhou XX Co., Ltd. cn test test xx linemanagerAD SMTP:test35.xx.ad@test.cn
astest36ad test36.xx.ad@test.cn xx test36 AD test36 ad 507F test xx xxxx test36.xx.ad@test.cn No. 55, Persiaran Selangor, Seksyen 50 GZ GD China Guangzhou XX Co., Ltd. cn test test xx linemanagerAD SMTP:test36.xx.ad@test.cn
astest37ad test37.xx.ad@test.cn xx test37 AD test37 ad 508F test xx xxxx test37.xx.ad@test.cn No. 55, Persiaran Selangor, Seksyen 51 GZ GD China Guangzhou XX Co., Ltd. cn test test xx linemanagerAD SMTP:test37.xx.ad@test.cn
astest38ad test38.xx.ad@test.cn xx test38 AD test38 ad 509F test xx xxxx test38.xx.ad@test.cn No. 55, Persiaran Selangor, Seksyen 52 GZ GD China Guangzhou XX Co., Ltd. cn test test xx linemanagerAD SMTP:test38.xx.ad@test.cn
批量創(chuàng)建AD賬號(hào)添加SMTP、Manager、extensionAttribute4屬性

  • PS1代碼如下:

PS C:\Users\xxx> $imports = Import-Csv -path 'C:\Users\xxx\Documents\Windows Server\Power Shell\
Bach AD PS\BulkAD_Final.csv' #導(dǎo)入CSV表格
PS C:\Users\xxx> foreach ($import in $imports) {

  $Path = "OU=xx5F,OU=xxx,OU=UserAcc,DC=CBACorp,DC=xxx,DC=asia"
  $Password = "xxxX123" #自行修改密碼
  $enabled = $True
  $changePW = $False  #取消UserMustChangePasswordAtNextLogon,F(xiàn)alse取消,Ture勾選
  $sam = $import.userid
  $upn = $import.upn
  $ini = $import.Initials
  $givenname = $import.fistname
  $surname = $import.lastname
  $displayname = $import.displayname
  $OfficeName = $import.office
  $telephoneNumber = $import.TelephoneNumber
  $email = $import.email
  $StreetAddress = $import.StreetAddress
  $L = $import.city
  $st = $import.province
  $co = $import.country
  $c = $import.c
  $mobile = $import.mobile
  $title = $import.title
  $department = $import.department
  $Company = $import.Company

#獲取表格manager列的成員OU對(duì)象
$Manager = Get-ADUser -Identity $import.manager -Properties * |Select-Object DistinguishedName
$employeeID = $import.employeeID
$name = $givenname + " " + $ini + " " + $surname
$postalCode = $import.postalCode
$fax = $import.fax
#定義自定義屬性
$custom = @{} #創(chuàng)建空的哈希表
$custom.proxyAddresses = $import.SMTP #給自定義屬性賦值
$custom.extensionAttribute4 = 'xxx' #給自定義屬性賦值
New-ADUser -name $name -SamAccountName $sam -UserPrincipalName $upn -DisplayName $displayname -GivenName $given
name -SurName $surname -Initials $ini -Office $OfficeName -OfficePhone $telephoneNumber -EmailAddress $email -StreetAddr
ess $StreetAddress -City $L -State $st -Country $c -MobilePhone $mobile -Title $title -Department $department -Company $
company -EmployeeNumber $employeeID -postalCode $postalCode -fax $fax -Path $path -AccountPassword (ConvertTo-SecureStri
ng $password -AsPlainText -force) -Enabled $enabled -ChangePasswordAtLogon $changePW -manager $manager -PassThru|

#添加attribute自定義屬性 -PassThrul后面可以用管道返回set-aduser命令
set-ADuser -add $custom
}
PS C:\Users\xxx>


分享標(biāo)題:批量創(chuàng)建AD賬號(hào)添加SMTP、Manager、extensionAttribute4屬性
文章網(wǎng)址:http://weahome.cn/article/gdcjss.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話(huà)咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部