Monday, November 5, 2018

Office 365 Profile Completeness: Finding users with no birthday set in the user profile

In Office 365, profile completeness is key to multiple cloud experiences. For example, you cannot really do approvals by the manager, if the manager is not set in the user’s profile! Another good example would be a people directory, which would be a bit useless if users don’t have their location and phone numbers filled in! In this series, we will look at how to use PowerShell to create a report of Office 365 Users missing key properties!

Finding users with no birthday

Office 365 Profile Completeness Series

Finding users with no birthday set in the user profile

In this blog post, we will focus on how to find users that did not set their birthday as part of their SharePoint Online profile. Honestly, one year ago, I never thought this was something I would write, because I didn’t think anyone used this. However, since I have joined Valo Intranet last December one of our most common requests has been a Birthday webpart! The webpart now exists, however, like anything else in tech, if you do not have the information in your profile, the webpart is a bit useless!

Finding users with no birthday

There is no out of the box report on Profile Completeness in Office 365, so PowerShell is your best tool in creating reports on user’s profiles! Here is what we will need to get started:

Requirements:

The Script:

First thing we are going to do is get our Office 365 credentials, and connect to both Azure Active Directory and the SharePoint Online Admin Center (with the PnP cmdlets)

$cred = get-Credential
Connect-AzureAD -Credential $cred
Connect-PnpOnline -Url https://globomanticsorg-admin.sharepoint.com/ -Credentials $cred

I will then get all of the users in my tenant, that are internal to the company (Member) and that have at least one license assigned to them.

$Users = Get-AzureADUser | Where {$_.UserType -eq 'Member' -and $_.AssignedLicenses -ne $null}

Next up, we will create an empty array in which we will later store our users without a birthday.

$NoBirthdayUsers = @()

Now that we have all our information, we will loop trough each user, and find out if they have a SharePoint Online Profile or not (since the birthday is stored in the SPO profile, not in Azure AD).   If the profile exists, and the SPS-Birthday property is equal to an empty string, it means the birthday for this user is not set, so we will save the user object in the array we created in the previous step!

foreach ($user in $Users) 
{
    $SPProfile  = Get-PnPUserProfileProperty -Account $user.UserPrincipalName -ErrorAction SilentlyContinue
        if ($SPProfile -ne $null)
        {
          if ($SPProfile.UserProfileProperties.'SPS-Birthday' -eq "")
            {
               $NoBirthdayUsers += $user
            }
        }
}

Lastly, we will export the results to a CSV file

$NoBirthdayUsers | Select DisplayName, UserPrincipalName | Export-Csv -Path "C:\O365Reports\UsersWithNoBirthday.csv" -NoTypeInformation

And here is the full script in one piece!

$cred = get-Credential
Connect-AzureAD -Credential $cred
Connect-PnpOnline -Url https://globomanticsorg-admin.sharepoint.com/ -Credentials $cred

$Users = Get-AzureADUser | Where {$_.UserType -eq 'Member' -and $_.AssignedLicenses -ne $null}
$NoBirthdayUsers = @()

foreach ($user in $Users) 
{
    $SPProfile  = Get-PnPUserProfileProperty -Account $user.UserPrincipalName -ErrorAction SilentlyContinue
        if ($SPProfile -ne $null)
        {
          if ($SPProfile.UserProfileProperties.'SPS-Birthday' -eq "")
            {
               $NoBirthdayUsers += $user
            }
        }
}
$NoBirthdayUsers | Select DisplayName, UserPrincipalName | Export-Csv -Path "C:\O365Reports\UsersWithNoBirthday.csv" -NoTypeInformation

The Result

The final result is a CSV file in which we can see the display names and user names of all of the users in our tenant that don’t have a birthday in their profile! You can either contact them individually, or even Send Email from PowerShell in Office 365 in order to automatically send them a nicely formatted HTML e-mail asking them to fill it!

Finding users with no birthday

More Resources

PowerShell for Office 365 is an essential tool as part of every Office 365’s administrator toolbox. Without PowerShell, you cannot do cool reports such as the one in this blog post, and you are missing out on multiple Office 365 reporting, productivity and security settings. Here are some resources that you could use to learn PowerShell for Office 365:

Books

Books are really ways to learn a topic from start to master, and even if they cost some dollars, they’re always a good investment!

Learn PowerShell for Office 365

Essential PowerShell for Office 365: Managing and Automating Skills for Improved Productivity
Take your Office 365 skills to the next level. Master PowerShell for Office 365 to stay competitive in today’s world of highly sought after cloud management skills. With expert guidance, IT pros will learn how to leverage the muscle of PowerShell to automate many advanced administrative tasks not otherwise accessible in the Office 365 Admin Center. You will discover how to unlock configuration options and automate tasks in order to free up valuable time and resources.

Get it on Amazon at the following links:

Video Training

NOTE: Pluralsight is a paid resource unlike Channel9, Youtube, and Microsoft Virtual Academy which are free. The quality they provide is also superior because of all the quality checks they go through, and the instructors are one of the best in the industry. The Pluralsight courses have a link to where you can get a free trial and decide for yourself if paying a subscription or not is worth it, but the 10 day free trial should allow you to view all those courses for free.

Learn PowerShell for Office 365

PowerShell for Office 365
In this course, you will learn how to use PowerShell to manage Office 365 services. You will learn how to connect and manage users and licensing, SharePoint Online, Exchange Online, Compliance Center and last but not least, Skype for Business Online.

Learn PowerShell for Office 365

PowerShell Playbook for Office 365
A more advanced look at multiple real-life scenarios that span across all Office 365 Services and show you how your PowerShell for Office 365 skills can be applied in your day to day life

PowerShell for common Office 365 Operations
In this 300 level session, you will learn how to automate the management of Office 365 using Windows PowerShell. We will discuss how to connect Windows PowerShell to Office 365, tour the Office 365 cmdlets, and demonstrate how to manage domains, users, and services including Exchange Online, and SharePoint Online.

Support Corner: Using PowerShell to Manage Office 365 Users
Join us in this fast-paced demo to learn how to manage Office 365 users using PowerShell. Experts show you how to create and delete users, update user IDs and passwords, assign licenses and groups, and much more.
Leave a comment and don’t forget to like the Absolute SharePoint Blog Page   on Facebook and to follow me on Twitter here  for the latest news and technical articles on SharePoint.  I am also a Pluralsight author, and you can view all the courses I created on my author page.

The post Office 365 Profile Completeness: Finding users with no birthday set in the user profile appeared first on Absolute SharePoint Blog by Vlad Catrinescu.


by Vlad Catrinescu via Absolute SharePoint Blog by Vlad Catrinescu

No comments:

Post a Comment