1

our current on-prem enviorment uses a external field to hold the employees birthday, this is then mapped to SPS-Birthday (on-prem). We have a SP Online instance to and I would like to get this birthday field to the online instance as well. I have exported a JSON list of the user account and the property field I need from SharePoint 2016 however I am struggling to import this into SharePoint Online with the provided API. The modified powershell runs successfully however the field is not being updated:

$adminUrl = "...admin.sharepoint.com" 
$userName = "..."
$pwd = Read-Host -Prompt 'Enter your password' -AsSecureString
$importFileUrl = "...Test%20Document%20Library/sample.txt"

$uri = New-Object System.Uri -ArgumentList $adminUrl
$context = New-Object Microsoft.SharePoint.Client.ClientContext($uri)

$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $pwd)
$o365 = New-Object Microsoft.Online.SharePoint.TenantManagement.Office365Tenant($context)
$context.Load($o365)

$userIdType=[Microsoft.Online.SharePoint.TenantManagement.ImportProfilePropertiesUserIdType]::Email

$userLookupKey="IdName"

$propertyMap = New-Object -type 'System.Collections.Generic.Dictionary[String,String]'
$propertyMap.Add("Property1", "Office")
$propertyMap.Add("Property2", "SPS-Birthday")

$workItemId = $o365.QueueImportProfileProperties($userIdType, $userLookupKey, $propertyMap, $importFileUrl);

$context.ExecuteQuery();

Write-Host "Import job created with following identifier:" $workItemId.Value

This is the sample file being used, I have tried using Birthday in 2 different formats and still nothing.

{
"value": [
    {
        "IdName": "email1@.com",
        "Property1": "JHB",
        "Property2": "1/11/2016  12:00:00 AM"
    },
    {
        "IdName": "email2@.com",
        "Property1": "JHB",
        "Property2": "1/13/2016  12:00:00 AM"
    },
    {
        "IdName": "email3@.com",
        "Property1": "JHB",
        "Property2": "January 14"
    }
]}

Really come to a roadblock with this and the help would be greatly apriciated please guys. Regards.

  • Just a small update on a recent discovery, I created another user property field to attempt the same script above (of type string). The script successfully updated this new field I had added but not the SPS-Birthday one. – Soprono Dec 6 '16 at 8:58
2

Try to add date in following format

$converteddate = "{0:MMM dd}" -f [datetime]$birthdate
  • Attempting that now Viraj, will update you on the feedback. The only issue there is adjusting the json extraction to get the date into that format. Once SP-Online refreshed Ill let you know the result. – Soprono Dec 6 '16 at 9:16
  • First, tyy with hard coded date. – Viraj Gorajia Dec 6 '16 at 9:21
  • Shall do, Just executed the script, thanks Viraj will post feedback as soon as I see any changes. – Soprono Dec 6 '16 at 9:23
  • Doesnt seem like the different formatting working. I could be wrong and missed the update cycle by a few minutes so Ill just keep checking for today and report back. – Soprono Dec 6 '16 at 10:57
  • Hey Viraj, the test ran overnight and still no luck with that format. – Soprono Dec 7 '16 at 6:22
1

Again thank you Viraj, I have added the solution here which has been scripted to extract from SharePoint 2016 and insert into SharePoint Online with no user interaction needed (other than basic variable setup) and into the correct format on my Github

In proper prospects of a answer the format I needed was MM/DD/YYYY.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.