PowerShell Script for Automated Update of Active Directory User Job Titles and Company
SV Example (users.csv):
SamAccountName,JobTitle,Office
PowerShell Script
# Import Active Directory module
Import-Module ActiveDirectory
# Path to the CSV file
$csvPath = "C:\Path\To\Your\users.csv"
# Import users from the CSV file
$users = Import-Csv -Path $csvPath
# Loop through each user from the CSV and update their attributes
foreach ($user in $users) {
$samAccountName = $user.SamAccountName
$jobTitle = $user.JobTitle
$office = $user.Office
# Get the user from AD
$adUser = Get-ADUser -Filter { SamAccountName -eq $samAccountName }
if ($adUser) {
# Update the Job Title and Office attributes
Set-ADUser -Identity $adUser -Title $jobTitle -Office $office
Write-Host "Updated Job Title and Office for $samAccountName to '$jobTitle' and '$office'"
} else {
Write-Host "User with SamAccountName $samAccountName not found."
}
}
Видео PowerShell Script for Automated Update of Active Directory User Job Titles and Company канала Sid Edu-Tech
SamAccountName,JobTitle,Office
PowerShell Script
# Import Active Directory module
Import-Module ActiveDirectory
# Path to the CSV file
$csvPath = "C:\Path\To\Your\users.csv"
# Import users from the CSV file
$users = Import-Csv -Path $csvPath
# Loop through each user from the CSV and update their attributes
foreach ($user in $users) {
$samAccountName = $user.SamAccountName
$jobTitle = $user.JobTitle
$office = $user.Office
# Get the user from AD
$adUser = Get-ADUser -Filter { SamAccountName -eq $samAccountName }
if ($adUser) {
# Update the Job Title and Office attributes
Set-ADUser -Identity $adUser -Title $jobTitle -Office $office
Write-Host "Updated Job Title and Office for $samAccountName to '$jobTitle' and '$office'"
} else {
Write-Host "User with SamAccountName $samAccountName not found."
}
}
Видео PowerShell Script for Automated Update of Active Directory User Job Titles and Company канала Sid Edu-Tech
Комментарии отсутствуют
Информация о видео
10 сентября 2024 г. 19:43:03
00:03:29
Другие видео канала