Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$site = "http://"
$context = Get-SPServiceContext -Site $site
$web = Get-SPWeb -Identity $site
$upCellPhone = "CellPhone"
$upExtTeleCountryCode = "ExtTeleCountryCode"
$upExtTelInlandPrefix = "ExtTelInlandPrefix"
$upMobTelPrefix = "MobTelPrefix"
$upMobTelNo = "MobTelNo"
$upExtTelLocalNo = "ExtTelLocalNo"
$upWorkPhone = "WorkPhone"
$upExtTelAreaCode = "ExtTelAreaCode"
$upExtFaxLocalNo = "ExtFaxLocalNo"
$upExtFaxAreaCode ="ExtFaxAreaCode"
$upFax = "Fax"
$vTeleNumber =""
$upm = New-Object -TypeName Microsoft.Office.Server.UserProfiles.UserProfileManager -ArgumentList $context
$userslist = Import-Csv -Path .\Profile.csv
for($count=0; $count -lt $userslist.Count; $count++)
{
#Create User Profile
$upm.CreateUserProfile($userslist[$count].EmployeeID)
$upm.Commit()
}
#Update Profile Property Values
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$userslist = Import-Csv -Path .\Profile.csv
foreach ($line in $userslist) {
$up = $profileManager.GetUserProfile($line.adDomainName + "\" + $line.adSAMAccountName)
$up['EmployeeID'].Value = $line.EmployeeID
$up['FirstName'].Value = $line.givenName
$up['SPS-PhoneticFirstName'].Value = $line.KnownAsGivenName
$up['LastName'].Value = $line.sn
$up['SPS-PhoneticLastName'].Value = $line.KnownAsLastName
$up['PreferredName'].Value = $line.DisplayName
$up['Department'].Value = $line.department
$up['Title'].Value = $line.title
$up['SPS-JobTitle'].Value = $line.WorkRole
$up['UserName'].Value = $line.adSAMAccountName
$up['ExtTeleCountryCode'].Value = $line.ExtTeleCountryCode
$up['ExtTelAreaCode'].Value = $line.ExtTelAreaCode
$up['ExtTelInlandPrefix'].Value = $line.ExtTelInlandPrefix
$up['ExtTelLocalNo'].Value = $line.ExtTelLocalNo
$up['MobTelPrefix'].Value = $line.MobTelPrefix
$up['MobTelNo'].Value = $line.MobTelNo
$up['ExtFaxAreaCode'].Value = $line.ExtFaxAreaCode
$up['ExtFaxLocalNo'].Value = $line.ExtFaxLocalNo
$up['IntFaxLocalNo'].Value = $line.IntFaxLocalNo
$up['IntFaxNumber'].Value = $line.IntFaxNumber
$up['IntFaxPrefix'].Value = $line.IntFaxPrefix
$up['IntTelLocalNo'].Value = $line.IntTelLocalNo
$up['IntTelNumber'].Value = $line.IntTelNumber
$up['IntTelPrefix'].Value = $line.IntTelPrefix
$up['Responsibilities'].Value = $line.Responsibilities
$up['Skills'].Value = $line.Skills
$up['Interests'].Value = $line.Interests
$up['WorkEmail'].Value = $line.mail
$up['InternalEmailAddress'].Value = $line.mailAddress
$up['Country'].Value = $line.co
$up['Company'].Value = $line.company
$up['CourtesyTitle'].Value = $line.personalTitle
$up['DepartmentNumber'].Value = $line.departmentNumber
$up['CountryCode'].Value = $line.c
$up['FunctionalManagerID'].Value = $line.ManagerID
$up['FunctionalManagerName'].Value = $line.managerFullName
$up['LineManagerID'].Value = $line.LineManagerID
$up['LineManagerName'].Value = $line.LineManagerName
$up['SecretaryID'].Value = $line.SecretaryEmplID
$up['OrganizationIdentifier'].Value = $line.ou
$up['WorkLocation'].Value = $line.l
$up['postalAddress'].Value = $line.postalAddress
#not sure this line
$up['ObjectSID-Str-From-SQL'].Value = $line.StringSID
#Update IsManager
if ($line.IsLineManager -eq "True")
{ $up['IsLineManager'].Value = $TRUE
}
else
{ $up['IsLineManager'].Value = $FALSE
}
#Update PictureURL
$up["PictureURL"].Value = "https://jpg" -f $up["EmployeeID"].Substring(0,4),$up["EmployeeID"]
# Update Mobile Number
if ($up[$upMobTelNo] -ne '' -or $up[$upMobTelNo] -ne $null)
{
if ($up[$upExtTelInlandPrefix] -ne '' -or $up[$upExtTelInlandPrefix] -ne $null)
{
$up[$upCellPhone].value = "+{0} ({1}) {2} {3}" -f $up[$upExtTeleCountryCode].value,$up[$upExtTelInlandPrefix].value,$up[$upMobTelPrefix].value,$up[$upMobTelNo].value
}
else
{
$up[$upCellPhone].value = "+{0} {1} {2}" -f $up[$upExtTeleCountryCode].value,$up[$upMobTelPrefix].value,$up[$upMobTelNo].value
}
}
else
{
$up[$upCellPhone].Value = ""
}
# Update Work Phone
if ($up[$upExtTelLocalNo] -ne '' -or $up[$upExtTelLocalNo] -ne $null)
{
$vTeleNumber = "{0}" -f $up[$upExtTelLocalNo]
#write-host $up[$upExtTelLocalNo].value
if ($up[$upExtTelAreaCode] -ne '' -or $up[$upExtTelAreaCode] -ne $null)
{
$vTeleNumber = "{0} {1}" -f $up[$upExtTelAreaCode], $vTeleNumber
}
if ($up[$upExtTelInlandPrefix] -ne '' -or $up[$upExtTelInlandPrefix] -ne $null)
{
$vTeleNumber = "({0}) {1}" -f $up[$upExtTelInlandPrefix], $vTeleNumber
}
if ($up[$upExtTeleCountryCode] -ne '' -or $up[$upExtTeleCountryCode] -ne $null)
{
$vTeleNumber = "+{0} {1}" -f $up[$upExtTeleCountryCode], $vTeleNumber
}
$up[$upWorkPhone].Value = $vTeleNumber
}
else
{
$up[$upWorkPhone].Value = ""
}
# Update External Fax Number
if ($up[$upExtFaxLocalNo] -ne '' -or $up[$upExtFaxLocalNo] -ne $null)
{
if ($up[$upExtTelInlandPrefix] -ne '' -or $up[$upExtTelInlandPrefix] -ne $null)
{
$up[$upFax].value = "+{0} ({1}) {2} {3}" -f $up[$upExtTeleCountryCode].value,$up[$upExtTelInlandPrefix].value,$up[$upExtFaxAreaCode].value,$up[$upExtFaxLocalNo].value
}
else
{
$up[$upFax].value = "+{0} {1} {2}" -f $up[$upExtTeleCountryCode].value,$up[$upExtFaxAreaCode].value, $up[$upExtFaxLocalNo].value
}
}
else
{
$up[$upFax].Value = ""
}
$up.Commit()
}