PS  Powershell Tutorial
  • Tutorials
  • File System
  • Learn PS
  • Scripting
  • PS With Technology
  • Commands
  • V6
  • Admin
  • AD
  • Questions
  • String Operations
  • More
    ✕
    Powershell Tutorials
    • Tutorials
    • Admin
    • Commands
    • V6
    • AD
    • String Operations
    Powershell Scripts
    • Questions
    • File System
    • Learn PS
    • Scripting
    • PS With Technology
    • Powershell Tutorial Start
    • Powershell Introduction
    • Differenciating between Objects Text
    • Exploring File System Navigation Manipulation
    • Finding Creating Using Variables
    • Working with PSProviders and PSDrives
    • Working With Registry Keys
    • Working with WMI CIM objects
    • Using Powershell 6.0 :- Create-shortcuts-lnk-or-url-files-with-powershell
    • Accessing the alias drive in powershell 3
    • Adding functions to the powershell ise menu
    • Basic line editing tricks powershell
    • Breaking down a powershell script
    • Casting values in powershell
    • Changing powershells look and feel
    • Constant and read only variables
    • Create xml variable powershell
    • Creating aliases in powershell
    • Creating and changing a powershell profile
    • Creating persistent aliases in powershell
    • Customizing the ise in powershell
    • Deleting aliases in powershell
    • Download file website powershell
    • Getting acquainted with the ise
    • Getting the right output in powershell
    • Getting to know tab expansion
    • Growing arrays dynamically in powershell
    • Handling complex powershell scripts
    • Hashtables in windows powershell
    • How to impersonate someone in powershell
    • How to use powershells invoke wmimethod
    • Installing windows powershell 2
    • Query XML data Powershell
    • Stringing powershell commands together 2
    • Understanding automatic variables in powershell
    • Understanding if else statements in powershell
    • Understanding powershell commands
    • Understanding powershell operators
    • Understanding powershell variables and datatypes
    • Understanding the windows management instrumentation wmi part ii
    • Understanding the windows management instrumentation wmi
    • Using loops in powershell part i
    • Using loops in powershell part ii
    • Using loops in powershell part iii
    • Using loops in powershell part-iv
    • Using loops in powershell part-v
    • Using pipelines to streamline powershell commands
    • Using regular expressions in powershell part-i
    • Using the switch statement in powershell
    • Working binary powershell
    • Working with powershell objects via variables
    • Writing your first powershell command
    Prev
    Next

    For single user you can use below script

    Example

    $Mobile = "+1234567890"
    Set-ADUser -Identity Joe.Doe -replace @{ 'MobilePhone' = $($Mobile) }
    

    Copy and Try it

    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;
        }
    }
    
    

    Copy and Try it

    Prev
    Next
    • Useful Resources
    • POWERSHELL SELECT STRING
    • AD
    • Questions
    • Admin
    PowershellTutorial

    of use and privacy policy.

    • Feedback
    Tutorials
    • String Operations
    • AD
    • Questions
    E-mail list

    Subscribe to PowershellTutorial email list and get Cheat Sheets, latest updates, tips & tricks about Powershell to your inbox.

    We respect your privacy.

    • HOME
    • Disclaimer
    • sitemap
    2018 PowershellTutorial.net. All Rights Reserved.