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
# 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