求大佬帮忙解读下下面的语句,刚学,不是很懂,谢谢
powershell吧
全部回复
仅看楼主
level 2
#-----------------------------------------------------------------------------------------------
# Script created by Chris Steding
#
# This script will update AD attributes for users imported from csv file
#
# csv file format:
# SamAccountName,Title,MobilePhone,OfficePhone,city,EmailAddress,Department,Office
#
# Remember to edit the -SearchBase to the correct domain name.
#-----------------------------------------------------------------------------------------------
# Import AD Module
Import-Module ActiveDirectory
write-Host 'Starting to update AD Attributes.......' -NoNewline -ForegroundColor Yellow
# Import CSV into variable $users
$users = Import-Csv -Path .\info12.csv
# Loop through CSV and update users if the exist in CVS file
foreach ($user in $users)
{
#Search in specified OU and Update existing attributes
Get-ADUser -Filter "SamAccountName -eq '$($user.samaccountname)'" |
#Set-ADUser -City $($user.City) -State $($user.State)
Set-ADUser -Description $($user.Description) -Title $($user.Title) -OfficePhone $($user.officephone) -MobilePhone $($user.mobile)
}
Write-Host 'done!' -ForegroundColor Green
2019年03月12日 03点03分 1
level 2
没有大佬吗
2019年03月13日 01点03分 2
level 2
耐心等待中~~~~
2019年03月13日 01点03分 3
level 3
就是一个利用excel添加域控用户的脚本
2019年04月29日 08点04分 4
level 1
这个脚本主要用处如下:
$users = Import-Csv -Path .\info12.csv | 本代码说明如下:
导入info12.csv 文件,此文件中包含有用户信息,同进将用户信息赋值给变量
foreach ($user in $users)
{
#Search in specified OU and Update existing attributes
Get-ADUser -Filter "SamAccountName -eq '$($user.samaccountname)'" |
#Set-ADUser -City $($user.City) -State $($user.State)
Set-ADUser -Description $($user.Description) -Title $($user.Title) -OfficePhone $($user.officephone) -MobilePhone $($user.mobile)
}
上述代码为利用Foreach循环,对每个账号遍历执行如下操作。
获取AD中账号属性信息,并设置描述、职位、电话、手机号等信息。
Set-ADUser -Description $($user.Description) -Title $($user.Title) -OfficePhone $($user.officephone) -MobilePhone $($user.mobile)
希望对你有所帮助。
2019年05月14日 10点05分 5
1