Hi Vinod Survase,
Please check if make sense for your case.
A sample PowerShell script that you can use as a starting point; (Path_to_your_CSV_file.csv).
CSV file with a list of users to be processed. The CSV file should have a column named ‘UserPrincipalName’ for the user to be converted, and ‘AssignTo’ for the user to whom the mailbox will be assigned.
# If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
# Import the required module
Import-Module MSOnline
# Connect to Microsoft 365
$credential = Get-Credential
Connect-MsolService -Credential $credential
# Import user data from CSV file
$users = Import-Csv -Path "Path_to_your_CSV_file.csv"
foreach ($user in $users) {
# Block the user
Set-MsolUser -UserPrincipalName $user.UserPrincipalName -BlockCredential $true
# Remove all licenses
$licenses = (Get-MsolUser -UserPrincipalName $user.UserPrincipalName).Licenses
foreach ($license in $licenses) {
Remove-MsolUserLicense -UserPrincipalName $user.UserPrincipalName -LicenseOptions $license
}
# Convert to shared mailbox and assign to another user
Set-Mailbox -Identity $user.UserPrincipalName -Type Shared
Add-MailboxPermission -Identity $user.UserPrincipalName -User $user.AssignTo -AccessRights FullAccess -InheritanceType All
}