Example
$Mobile = "+1234567890"
Set-ADUser -Identity Joe.Doe -replace @{ 'MobilePhone' = $($Mobile) }
for all users - want to capture city and country from any valid user and update for all users,
you can create list and load list of users to update their properties
I want to update city and country only
Example
#any valid user whose property you want to apply all users
$username = "anyvalidADuser"
#fetch properties example, here i want to capture city and country -- AD field name for city is 'l', country 'co'
$userprops = @{
country = get-aduser $username -Properties co | ForEach-Object {$_.co};
City = get-aduser $username -Properties l | ForEach-Object {$_.l};
}
$users = Get-ADUser -Filter * -SearchBase $ou |Select-Object SamAccountName | ForEach-Object {$_.SamAccountName}
foreach ($user in $users)
{
set-aduser -identity $user -Replace @{
co = $userprops.country;
l = $userprops.city;
}
}