Prompt the user for their username. This ensures only authorized users update their own details.
$Username = Read-Host "Enter your username"Prompt users for new details. This script collects updated contact information.
$PhoneNumber = Read-Host "Enter your new phone number"
$OfficeLocation = Read-Host "Enter your new office location"Modify the AD user attributes. This updates the user's mobile number and office location in AD.
Set-ADUser -Identity $Username -MobilePhone $PhoneNumber -Office $OfficeLocation Write-Host "Your details have been updated."Run this script regularly using Task Scheduler. This ensures user details are updated on a scheduled basis.
$trigger = New-ScheduledTaskTrigger -Daily -At "08:00AM"
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File C:\Scripts\UpdateADDetails.ps1" Register-ScheduledTask -TaskName "UserSelfUpdate" -Trigger $trigger -Action $action -User "SYSTEM"Update user details in AD using the script below:
Set-ADUser -Identity username -Email "newemail@domain.com" -OfficePhone "1234567890"Yes, multiple attributes can be updated at once using the script below:
Set-ADUser -Identity username -Title "New Title" -Department "IT"Admin approval depends on permissions. Some attributes require admin rights.