Office 365 – Update User Profile Property using PowerShell and CSOM

Here is a quick tip on how you can automate the update of Office 365 user profile property using the PowerShell and Client Side Object Model (CSOM).

 

$filePath = "D:\SCRIPTS\OFFICE365"
Set-Location $filePath
Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Runtime.dll")
Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.UserProfiles.dll")

Write-host "Client Library Module(s) Loaded...." -ForegroundColor Green
# Authenticate
$userName = "YOUR USERNAME" 
$siteUrl = "YOUR SITE COLLECTION URL"
$pwd = Read-Host -AsSecureString "Please enter your password"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) 
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $pwd)
$peopleManager = new-object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($ctx);
$personProperties = $peopleManager.GetMyProperties();
$ctx.Load($personProperties);
$ctx.ExecuteQuery();
$peopleManager.SetSingleValueProfileProperty($personProperties.AccountName, "AboutMe", "I LOVE OFFICE 365 !!!");
$ctx.ExecuteQuery();

Office 365 – Power BI Preview now available worldwide

Today Microsoft announced that Power BI preview will be available world wide. Power BI is cloud based BI service for power users. Users can bring their data to real life and can create dashboard just using the browser.

You can read more about this at the Microsoft Business Intelligence blog post.

http://blogs.msdn.com/b/powerbi/archive/2015/03/16/power-bi-preview-now-available-worldwide.aspx

Quick Tip: Office 365 – Document Upload and metadata

One of my client recently reported an interesting point when uploading document to Office 365 document library in SharePoint Online. I wanted to share the experience and workaround we used for this.

Typically (on-prem) when you have a metadata in your document library, after uploading document, SharePoint will take you straight to metadata screen. Where you will have option to enter metadata and then document will be checked-in. Now for on-prem version it works like this even if your metadata are not mandatory. So for example you have two metadata in your document library and both are not mandatory  SharePoint will still give you an option to pick metadata before checking-in the document.

This is not the default behavior with Office 365. In SharePoint Online if your metadata are not mandatory SharePoint will check document in without prompting you to enter your metadata. From my experience I can tell that this behavior will not work for most of the business users. 🙂

The solution (or workaround if you will) was rather simple in this case. All you have to do is go to Document Library setting and turn on the “Allow Management of Content Types” to True. Do not make any other changes but just turn the content type management to ON and that will bring SharePoint to sense and it will then start showing you the Metadata page. 🙂

I am not 100% sure the reason behind this change in behavior and still in process of figure out why this change was implemented in Office 365.

If you are using your metadata as part of your Content Type (which I think should be the case for the most part) then you are golden.

Cheers.

Office 365 – Approval workflow (SP 2010) missing in your site collection

This is bit odd behavior but you will notice that sometimes in your Office 365 site collection you do not have option to add SharePoint 2010 approval workflow. You will see all the other workflows i.e. SharePoint 2010 Disposition, SharePoint 2010 Collect Signature etc but you do not have option to pick Approval workflow.

I tried researching on this issue and only workaround that I have found so far is that deactivate the “Workflows” site collection feature and reactivate it again.

The challenge with this approach is that many times you are already using other workflows which comes as a part of “Workflows” and many instances are already in flight and the million dollar question is what happens to those workflows when you pull the trigger and de-activate the workflow.

Honestly I do not have the official answer for this but I have faced this issues and my recommendations are as follows.

1) Make sure your all your workflows are set to no new instances.

2) If possible complete all your inflight workflows.

3) Where possible take the backup.

After performing above steps you can go ahead and de-activate the “Workflow” feature and re-activate it again and your “SharePoint 2010 Approval” workflow should show up.

Just to verify the behavior I de-activate the feature with existing inflight workflows and re-activate the feature and all my in flight workflows were running just fine.

Having said that I would follow the above recommendation in Production.

Office 365 API Sandbox and C# Support

Today Microsoft announced that their API Sandbox for Office 365 API will now have support for C#. Initially when it was released last year it only supported JavaScript.

API Sandbox runs your code in a “sandbox” environment which MS set it up. You can validate your code simply by clicking the “Run” button. Results will be displayed in the “Console” panel underneath the code snippets.

Visit the API Sandbox Here: https://apisandbox.msdn.microsoft.com/

You can read more about it at the following blog post.

http://blogs.msdn.com/b/exchangedev/archive/2015/02/24/announcing-c-support-in-the-api-sandbox-for-office-365-apis.aspx

Sample Data:

If you want to know more about Sample data you can read the following article. This article shows the data that is associated with the sample user in the sample tenant:

https://msdn.microsoft.com/en-us/office/office365/howto/sample-tenant-data

Office 365 and SharePoint Designer 2013 Error – Access Denied.

Recently when working with Office 365 I was bit surprised to see that when I try to add a new site theme I was getting Access Denied error. I verified and double checked that I have all the required permission but still no dice.

So I Binged and came across this article. As per the article you will get this error if you have not turned on the option to run the custom script. This option by default is turned off in SharePoint Admin section.

To check this go to your tenant SharePoint Admin section and click Settings from the left navigation. Scroll down and you should see a section for custom script.

CustomScript

As mentioned in the article above click both allow options and wait for some time for your SharePoint Designer to start obeying you. 🙂

I would highly recommend you read the original article as it also has PowerShell way of turning this feature.