AD新建用户、组、OU

#新建用户

import-csv d:\AD\Users.csv | Foreach {New-ADUser -Name $_.Name -Path $_.Path -samAccountName $_.SamAccountName -UserPrincipalName $_.Userprincipalname -Enabled $true -AccountPassword (ConvertTo-SecureString $_.AccountPassword -AsPlainText -force) -passthru -PasswordNeverExpires ($_.PasswordNeverExpires -eq "1")}

#删除用户

get-aduser -filter * -SearchBase "ou=oo,ou=admins,dc=ddv,dc=com" |? {$_.name -eq "test02"} | Remove-ADUser -Confirm:$false

#新建组
import-csv d:\AD\Groups.csv | Foreach {New-ADGroup -Name $_.GroupName -Path $_.Path -GroupScope Global}

#将用户加入组
import-csv d:\AD\Members.csv | Foreach {Add-ADGroupMember -Identity $_.Memberof -Members $_.Users}

#新建OU
import-csv d:\AD\OU.csv | Foreach {New-ADOrganizationalUnit -Name $_.OUName -Path $_.OUPath}

#导入组策略
import-csv C:\ADPS\GPO.csv | Foreach {import-gpo -BackupId $_.BackupID -TargetName $_.TargetName -path "C:\ADPS\GPO\" -CreateIfNeeded}
#链接组策略
import-csv C:\ADPS\GPLink.csv | Foreach {New-GPLink -Name $_.TargetName -Target $_.OU -LinkEnabled Yes}

新建寻呼机字段(pager):

Set-ADUser -Credential $cred $AccountName -replace @{pager=$AccountNumber}

上一篇:C# 特性Attributes 和反射


下一篇:Unix安装BerkeleyDB