Mail Box
Steps to RUN PowerShell Script
1) PowerShell Version
Please use below command to check PowerShell Version.
Get-Host | Select-Object Version
2) Update PowerShell Version
If PowerShell Version less than 5, Please install the following
Windows Management Framework 5.1
.NET Framework 4.5.2 (or newer)
Download link for the above software’s
.NET Framework 4.5.2 – https://www.microsoft.com/en-in/download/details.aspx?id=42642
Windows Management Framework 5.1- https://www.microsoft.com/en-us/download/details.aspx?id=54616
3) Restart Machine
Restart the machine and check the PowerShell version again with below command
Get-Host | Select-Object Version
4) Run the PowerShell script
Now script will run without any issues.
Powershell Script
set-executionpolicy unrestricted
Install-Module -Name ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline
Get-Mailbox -ResultSize Unlimited | Select-Object PrimarySmtpAddress, RecipientTypeDetails | Export-CSV UserTypeList1.csv
$env:PSModulePath=$env:PSModulePath+”;”+”C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell”
Install-Module -Name “AzureAD”
# Connect to AzureAD
Connect-AzureAD
# Get CSV content
$CSVrecords = Import-Csv C:\Windows\system32\UserTypeList1.csv
# Create arrays for skipped and failed users
$SkippedUsers = @()
$FailedUsers = @()
# Loop trough CSV records
foreach ($CSVrecord in $CSVrecords) {
$upn = $CSVrecord.PrimarySmtpAddress
$user = Get-AzureADUser -Filter “userPrincipalName eq ‘$upn’”
if ($user) {
try{
if($CSVrecord.RecipientTypeDetails -eq “SharedMailbox”) {
$user | Set-AzureADUser -Department ‘#SB’
}
} catch {
$FailedUsers += $upn
Write-Warning “$upn user found, but FAILED to update.”
}
}
else {
Write-Warning “$upn not found, skipped”
$SkippedUsers += $upn
}
}
# Array skipped users
# $SkippedUsers
# Array failed users
# $FailedUsers
Knowledge Base
SharePoint Add-ins are retiring: Welcoming the SharePoint SPFx Solutions web parts
Microsoft’s evolution in content and process automation has taken a significant leap with the SharePoint…..

Unlocking Efficiency: Enhancing Performance Management with SharePoint-based Software
Welcome, HR professionals! Are you looking for a user-friendly and efficient solution to…

Fostering Seamless Employee Onboarding – Your Definitive Handbook
Welcome, HR professionals! Are you looking for a user-friendly and efficient solution to streamline your performance management processes?

How to Create a SharePoint Ticketing System: A Step-by-Step Guide
In today’s fast-paced business environment, efficient issue tracking and support ticket management……

Seamlessly Integrate SharePoint Framework Web Parts in Microsoft Teams
Collaboration and seamless integration are critical in today’s digital environment for increasing productivity…

How to deploy SPFx web part on SharePoint Online
Microsoft’s SharePoint Framework (SPFx) client web component is a development approach for building…

How to setup SharePoint Framework development environment to develop SharePoint custom web parts and Microsoft Teams Apps
Developing custom web parts and Microsoft Teams applications with SharePoint Framework (SPFx) requires…

Creating Your First SPFx Client-Side Web Part
SharePoint framework (SPFx) is a powerful development model provided by Microsoft for building client-side…

How to create an Employee Directory in SharePoint
Nobody wants to go through with the tons of paperwork and manual approach nowadays. Business success…