none
updating Properties in AD RRS feed

Answers

  • This is how my CSV looks.
    “Name”,”samaccountname”,”Country”
    “Lab User A”,”labusera”,”BH”
    “Lab User B”,”labuserb”,”IN”
    “Lab User C”,”labuserc”,”US”
    “Lab User D”,”labuserd”,”UK”

    #—Script—
    $users = Import-Csv -Path C:\reports\userlist.csv

    foreach($user in $users){
    #SAMAccountName should be in CSV
    Set-ADUser $user.samaccountname -Country $User.country
    }

    #check Output
    Get-ADUser -Filter * -Properties * | where{$_.Name -like “Lab*”} | select Name,SamAccountname,Country

    #—Output—
    Name SamAccountname Country
    —- ————– ——-
    Lab User A labusera BH
    Lab User B labuserb IN
    Lab User C labuserc US
    Lab User D labuserd UK


    • Marked as answer by 07Venky Wednesday, December 13, 2017 11:31 AM
    Wednesday, December 13, 2017 11:31 AM

All replies

  • Monday, December 11, 2017 11:54 AM
  • Thank you the reply, Aim not asking for any kind of script to write. 

    From Powershell  works when it is defined as below highlighted.

    If ($Country -eq "United Kingdom") {$Country = "GB"} # {Out-File $logfile -append}
    IF ($Country -ne '' ) { Set-ADUser -server $ADServer -Credential $GetAdminact -Identity $sam  -Country $Country } 

    when creating a new joiner account of different country users, fetching the data from a csv file does not update the country.


    • Edited by 07Venky Monday, December 11, 2017 12:56 PM
    Monday, December 11, 2017 12:55 PM
  • There is no CAV in your code.  Perhaps you could start by learning basic PowerSHell which will show you how to use loops and CSV files.

    Also read:

    help Import-Csv -Online
    about_ForEach


    \_(ツ)_/

    Monday, December 11, 2017 1:21 PM
  • This is how my CSV looks.
    “Name”,”samaccountname”,”Country”
    “Lab User A”,”labusera”,”BH”
    “Lab User B”,”labuserb”,”IN”
    “Lab User C”,”labuserc”,”US”
    “Lab User D”,”labuserd”,”UK”

    #—Script—
    $users = Import-Csv -Path C:\reports\userlist.csv

    foreach($user in $users){
    #SAMAccountName should be in CSV
    Set-ADUser $user.samaccountname -Country $User.country
    }

    #check Output
    Get-ADUser -Filter * -Properties * | where{$_.Name -like “Lab*”} | select Name,SamAccountname,Country

    #—Output—
    Name SamAccountname Country
    —- ————– ——-
    Lab User A labusera BH
    Lab User B labuserb IN
    Lab User C labuserc US
    Lab User D labuserd UK


    • Marked as answer by 07Venky Wednesday, December 13, 2017 11:31 AM
    Wednesday, December 13, 2017 11:31 AM