test-attribue


get-ADUser test-snxt -Properties * | select mobile

https://takeafile.com/?f=rihivuxera

# Import AD Module
Import-Module ActiveDirectory

# Import CSV into variable $userscsv
#$userscsv = import-csv D:\areile\Desktop\adtest.csv
$users = Import-Csv -Path D:\Yogi\Template.csv
# Loop through CSV and update users if the exist in CVS file

foreach ($user in $users) {
#Search in specified OU and Update existing attributes
Get-ADUser -Filter “SamAccountName -eq ‘$($user.samaccountname)'” -Properties *  |
Set-ADUser -givenname $($user.givenname) -City $($user.City) -mobile $($user.mobile) -state $($user.state) -country $($user.country)
}

#Samaccountname    GivenName     MiddleName    Sn    mail    mobile    business    company    extensionattribute2    Department    extensionattribute3    manager    city    state    country


Import-Module -Name ActiveDirectory
$Data = Import-Csv D:\Yogi\Template.csv
foreach ($User in $Data)
{

$SamAccountName = $User.SamAccountName
if (Get-ADUser -Filter {sAMAccountName -eq $SamAccountName})
{

Set-ADUser -Identity $SamAccountName -country “IN”

}

}
——————————————————

Import-Module -Name ActiveDirectory
$Data = Import-Csv D:\Yogi\Template.csv
foreach ($User in $Data)
{

#Samaccountname    GivenName     MiddleName    Sn    mail    mobile    business    company    extensionattribute2    Department    extensionattribute3    manager    city    state    country

$SamAccountName = $User.SamAccountName
$givenname = $user.givenname
$middlename = $user.middlename
$mail = $user.mail
$company = $User.company
$business = $User.businessv
$extensionattribute2 = $User.extensionattribute2
$Extensionattribute3 = $User.Extensionattribute3
$country = $user.country
if (Get-ADUser -Filter {sAMAccountName -eq $SamAccountName})
{

Set-ADUser -Identity $SamAccountName -Replace @{

givenname=”$givenname”;
middlename=”$middlename”;
sn=”$sn”;
mail=”$mail”;
company=”$company”;
business=”$business”;
extensionattribute2=”$extensionattribute2″;
extensionattribute3=”$extensionattribute3″}

Set-ADUser -Identity $SamAccountName -country “IN”

}

else
{

Out-File -InputObject “$SamAccountName does not exists in abgplanet.abg.com domain” -FilePath “D:\Yogi\Errors.txt” -Append

}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: