Hello @lalajee
i believe u are looking for this.
# Connect to Exchange on-premises
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<your on-premises Exchange server>/PowerShell/ -Authentication Kerberos
Import-PSSession $Session
# Prompt for shared mailbox name and member email addresses
$SharedMailboxName = Read-Host "Enter the name of the shared mailbox"
$MemberEmails = Read-Host "Enter the email addresses of the members separated by a semicolon (;)"
# Create shared mailbox on-premises
New-Mailbox -Name $SharedMailboxName -Alias $SharedMailboxName -Shared
# Add members to shared mailbox on-premises
$MemberEmailsArray = $MemberEmails.Split(';')
ForEach ($MemberEmail in $MemberEmailsArray) {
Add-MailboxPermission -Identity $SharedMailboxName -User $MemberEmail -AccessRights FullAccess -InheritanceType All
}
# Synchronize shared mailbox to Exchange Online
New-MoveRequest -Identity $SharedMailboxName -RemoteLegacy -RemoteGlobalCatalog "<your on-premises domain controller>" -TargetDeliveryDomain "<your domain>.onmicrosoft.com" -TargetDatabase "<your on-premises mailbox database>"
# Disconnect from Exchange on-premises
Remove-PSSession $Session
I hope this is work for u.
and please, don`t forget to upvote if this help u.
Regards