SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.01k forks source link

Help Needed - New-Object : Cannot find an overload for "Office365Tenant" and the argument count: "1". #3880

Closed Rocket101101 closed 5 years ago

Rocket101101 commented 5 years ago

Hello there,

I've tried the PowerShell script as mentioned in the article however cannot get through the following error message -

New-Object : Cannot find an overload for "Office365Tenant" and the argument count: "1". At line:17 char:9

  • $o365 = New-Object Microsoft.Online.SharePoint.TenantManagement.Office...

I believe this is where the error is generated:

$o365 = New-Object Microsoft.Online.SharePoint.TenantManagement.Office365Tenant($Context)

Any comment would be appreciated! Thanks a lot!

The full script is almost same as in the article: [System.Reflection.Assembly]::LoadFile("C:\Program Files\PackageManagement\NuGet\Packages\Microsoft.SharePointOnline.CSOM.16.1.8810.1200\lib\net45\Microsoft.SharePoint.Client.dll") | Out-Null [System.Reflection.Assembly]::LoadFile("C:\Program Files\PackageManagement\NuGet\Packages\Microsoft.SharePointOnline.CSOM.16.1.8810.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.dll") | Out-Null [System.Reflection.Assembly]::LoadFile("C:\Program Files\PackageManagement\NuGet\Packages\Microsoft.SharePointOnline.CSOM.16.1.8810.1200\lib\net45\Microsoft.Online.SharePoint.Client.Tenant.dll") | Out-Null

# Get needed information from the end user $adminUrl = "https://kcontoso-admin.sharepoint.com" #Read-Host -Prompt 'Enter the admin URL of your tenant' $userName = "admin@contoso.onmicrosoft.com" #Read-Host -Prompt 'Enter your user name' $pwd = Read-Host -Prompt 'Enter your password' -AsSecureString $importFileUrl = Read-Host -Prompt 'Enter the URL to the file located in your tenant'

# Get instances to the Office 365 tenant using CSOM $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)

# Type of user identifier ["Email", "CloudId", "PrincipalName"] in the user profile service $userIdType=[Microsoft.Online.SharePoint.TenantManagement.ImportProfilePropertiesUserIdType]::Email

# Name of user identifier property in the JSON $userLookupKey="idName"

# Create property mapping between the source file property name and the Office 365 property name # Notice that we have here 2 custom properties in UPA called 'City' and 'OfficeCode' $propertyMap = New-Object -type 'System.Collections.Generic.Dictionary[String,String]' $propertyMap.Add("City", "City") $propertyMap.Add("Office", "OfficeCode")

# Call to queue UPA property import $workItemId = $o365.QueueImportProfileProperties($userIdType, $userLookupKey, $propertyMap, $importFileUrl);

# Execute the CSOM command for queuing the import job $context.ExecuteQuery();

# Output the unique identifier of the job Write-Host "Import job created with the following identifier:" $workItemId.Value


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

msft-github-bot commented 5 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

Rocket101101 commented 5 years ago

Following the instructions in https://github.com/SharePoint/PnP/tree/master/Samples/UserProfile.BatchUpdate.API. The issue is gone! Thanks!

ghost commented 5 years ago

Actually this error is still there. I've downloaded the version from GitHub and it still errors on the same line.

msft-github-bot commented 4 years ago

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues