Thursday, June 20, 2019

Using MFA Accounts to connect to SPO online using PnP

Recently our organization have MFA (Multi-factor Authentication) enabled on all the Admin IDs. Which means once you are authenticated, you will be challenged again to prove your identity by giving a authentication code which will be sent to your mobile or MSFT calls your authorized identity phone to confirm its you who are logging in. Until now we used to store the password in an encrypted key and passed those credentials in the script. After MFA enabled, we need to use the paramter called 'use-weblogin'. Once this parameter is used who will be challenged second time while running the script, after successful verification rest of the script runs.

For instance Before MFA our code for connection
Connect-PnPOnline -Url https://yourAdminPortalURL -Credentials (Get-Credential)

After MFA our code for connection
Connect-PnPOnline -Url https://yourAdminPortalURL -UseWebLogin

Kindly let me know if there is any other ways to run the admin scripts automatically without weblogin paramter. May be there is way using Function and Azure Run books, i haven' explored that route much. Thanks for taking time to read this.



Tuesday, March 3, 2015

There was an error generating the XML document

There was an  issue i had encountered today while starting workflow using Nintex. The following thread helped me. 

While trying to start the workflow, it is failing while "Assigning Task to Apprver" basically in Nintex Language at "Request Approval" action item. 

The issue is the title contains some hidden characters. I copied the title and pasted in Notepad and found that there is one Escape character which is causing the workflow to fail. I cleaned up that character and after that workflow started working fine. 

Simple Fix! Isn't it? 



Monday, February 16, 2015

The specified URL is not a top-level Web site

While doing site Backup and Restore in SharePoint 2013, i was getting the following error. Please note that the site collection is Host Name Site collection not Path based site collection.

The command i was giving is

PS C:\Windows\system32> Restore-SPSite -Path "D:\Backup\MYTESTSITE1-PROD-20150210-2351.bak" -DatabaseName "SP13_Content_TESTSITEDB" -HostHeaderWebApplication "http://WFESERVERNAME" -Force 

The specified URL is not a top-level Web site. The backup and restore operations work only for top-level Web sites. Enter the URL for a site to try the

operation again.

At line:1 char:1
+ Restore-SPSite -Path "D:\Backup\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...dletRestoreSite:SPCmdletRestoreSite) [Restore-SPSite], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletRestoreSite

The only thing that worked for me is 

- Deleting the existing site collection using the Remove-Spsite powershell cmdlet.
- Restoring the site from Backup using Restore-Spsite powershell cmdlet targeting to specific content DB

Remove-SPSite -Identity "" -GradualDelete

Restore-SPSite -Path "D:\Backup\MyTestSite1.bak" -DatabaseName "SP13_Content_TestSitesContentDB" -HostHeaderWebApplication "http://WFESERVERNAME"

Hope this helps for some one who is having similar issue in backing up and restoring Host Name Site Collection (HNSC)

If someone finds a reason for this or is there any other way of doing this restore please let me know. 



Friday, February 13, 2015

Export-SpWeb : The URL provided is invalid

While running the Export command for exporting the list from one site to another, i was giving the exact syntax but giving me the following error.

Export-SPWeb -Path "D:\SharePointBackUps\MyTestList.bak" -ItemUrl "" -IncludeUserSecurity -IncludeVersions All

Export-SPWeb : The URL provided is invalid. Only valid URLs that are site collections or sites are allowed to be exported using
At line:1 char:1
+ Export-SPWeb -Identity -Path "D: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...CmdletExportWeb:SPCmdletExportWeb) [Export-SPWeb], SPException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletExportWeb

Annoying, isn't it?

After reading the some of the blogs, the following link helped me 

After giving the following syntax it worked. The issue occurring at -ItemUrl parameter. After giving in the format Lists/LISTNAME it worked.

Export-SPWeb -Path "D:\SharePointBackUps\MyTestList.bak" -ItemUrl "Lists/MyTestList" -IncludeUserSecurity -IncludeVersions All

The reason is at the background Get-SPWeb cmdlet is calling SPWeb.GetList(), before calling this function it prepends SPWeb.ServerRelativeUrl and an extra forward slash "/".



Wednesday, December 3, 2014

Your changes were saved but could not be uploaded because of an error

This is the issue with the SharePoint 2010 office file not uploaded to SharePoint. What happens is when the user trying to download a copy from the SharePoint site and makes changes to it and uploads it back. Office 2010 suite and SharePoint, there is a medium called 'Microsoft Document upload Center' acts as medium between office files and SharePoint site.

When opening the document from the server, the Microsoft Upload Center stores a local copy in its cache, and when the user makes the changes, the changes are first updated and local copy when saved, the changes from "Document Cache" which is in Microsoft Upload center gets updated back to the SharePoint site.

Sometimes due to network connectivity issues, the file may file to upload to SharePoint after user finished with changes. When we open the same file from the SharePoint you would get the following error

'Your Changes were save but could not be uploaded because of an error. You may be able to upload the file using the server Web page'

Most probable reason could be sitting in Microsoft Document Upload Center. To resolve this issue follow these steps

Step1: Access the Microsoft Document Upload Center from the 'Task Manager'

Step2: Look for any Cache errors.

Step3: Save the local copy if required.
Step4: Clear the Cache, this will remove the entire cache. or Discard the changes to file only that should remove the cache.

Step5: Try opening the file from SharePoint and save it back. That error pop up in the Document should go away.

Sunday, October 26, 2014

An error occurred while trying to load some required components

An error occurred while trying to load required components in Visual Studio 2012

This could be the case happening while installing Office Developer Tools in offline mode and then started creating SharePoint projects using Visual Studio 2012

An error occurred whilst trying to load some required components, Please ensure the following prerequisite components are installed.

Microsoft Web Developer Tools

Microsoft Exchange Web Services

The possible reason could be while installing the Office Developer tools and prerequisites, the office web installer sets some parameters mapped to GAC, which is not done while installed in offline mode according to following link

The fix this try the following steps:
- To un-install Microsoft Exchange Web Services from Control Panel
- Open the 'Command Prompt' with Administrator Previliges
- Navigate to location of file EWSManagedApi32.msi from the Command Prompts
- Run the following command. Make sure to be in single line. There is 'space' between .msi  and addlocal

  EwsManagedApi32.msi addlocal="ExchangeWebServicesApi_Feature,ExchangeWebServicesApi_Gac"

- The installation of the Exchange Web Services Api finishes. This commands does the installation and as well as maps the required dll files in GAC.
- Try closing any open instances of Visual Studio. Restart the Visual Studio
- Enjoy creating SharePoint Projects.

Hope this helps!



Saturday, October 25, 2014

SharePoint Connection Error

SharePoint Connection Error While Adding Visual Web Part: 

While creating the web part in SharePoint 2013, in the SharePoint customization wizard, i got the following error

While developing web part, Visual Studio creates file structure to debug and deploy the solution. After some searching in google i came to know that, the following are the causes for failure in my case:

- The service account (used for development) did not have login priviliges for SQL Server
- The service account (used for development) did not have dbOwner permissions for specified content DB
- The service account (used for development) did not have read and write access to Config DB.

Once all these conditions are satisfied i can finally connect to SharePoint site via Visual Studio