Domanda

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.

È stato utile?

Soluzione 2

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.

Altri suggerimenti

Try to add date in following format

$converteddate = "{0:MMM dd}" -f [datetime]$birthdate
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top