# Trying to migrate group emails to shared mailbox

**URL:** <https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836>\
**Category:** PowerShell Help\
**Created:** [July 8, 2022, 3:11pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836 "2022-07-08T15:11:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ericnelson699](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@Ericnelson699](https://forums.powershell.org/u/Ericnelson699)\
**Post date:** [July 8, 2022, 3:11pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/1 "2022-07-08T15:11:12Z")

</div>

here is the code I put :

```auto
$deletedGroup= Get-Mailbox -SoftDeletedMailbox -GroupMailbox -Filter {name -like "Test group 2"} 
$targetuser=get-mailbox -Identity Bills@carlotz.com
New-MailboxRestoreRequest -SourceMailbox $deletedGroup.DistinguishedName -TargetMailbox $targetuser.DistinguishedName -AllowLegacyDNMismatch -Verbose

```

\*\*my error says to provide a value for -SourceMailbox but I am providing one by putting the variable that I created there \*\*

---

<div class="post-metadata">

**Author:** ![Ericnelson699](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@Ericnelson699](https://forums.powershell.org/u/Ericnelson699)\
**Post date:** [July 8, 2022, 3:13pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/2 "2022-07-08T15:13:55Z")

</div>

Here is the error message:

```auto
PS C:\Windows\system32> $deletedGroup= Get-Mailbox -SoftDeletedMailbox -GroupMailbox -Filter {name -like "Test group 2"} 
$targetuser=get-mailbox -Identity Bills@carlotz.com
New-MailboxRestoreRequest -SourceMailbox $deletedGroup.DistinguishedName -TargetMailbox $targetuser.DistinguishedName -AllowLegacyDNMismatch -Verbose
Cannot validate argument on parameter 'SourceMailbox'. The argument is null. Provide a valid value for the argument, and then try running the command again.
    + CategoryInfo : InvalidData: (:) [New-MailboxRestoreRequest], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,New-MailboxRestoreRequest
    + PSComputerName : outlook.office365.com

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 8, 2022, 3:26pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/3 "2022-07-08T15:26:19Z")

</div>

> [@Ericnelson699](#):
>
> \*\*my error says to provide a value for -SourceMailbox but I am providing one by putting the variable that I created there \*\*

Did you check the content of the variable you want to use? Try to use the subexpression operator.

---

<div class="post-metadata">

**Author:** ![Ericnelson699](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@Ericnelson699](https://forums.powershell.org/u/Ericnelson699)\
**Post date:** [July 8, 2022, 4:54pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/4 "2022-07-08T16:54:29Z")

</div>

how do/would I use the sub-expression operator?

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 8, 2022, 6:21pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/5 "2022-07-08T18:21:53Z")

</div>

Have you at least tried to google it?

---

<div class="post-metadata">

**Author:** ![Ericnelson699](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@Ericnelson699](https://forums.powershell.org/u/Ericnelson699)\
**Post date:** [July 8, 2022, 6:45pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/6 "2022-07-08T18:45:24Z")

</div>

I did but I did not understand the usage but on another note I did get the above command to work it had something to do with the variable I created

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [July 8, 2022, 7:20pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/7 "2022-07-08T19:20:26Z")

</div>

Great to hear that. 👍🏽

How about sharing your solution with the world? That could help others comming here looking for a solution for the same or a similar issue. 😉

---

<div class="post-metadata">

**Author:** ![Ericnelson699](https://avatars.discourse-cdn.com/v4/letter/e/a6a055/32.png) [@Ericnelson699](https://forums.powershell.org/u/Ericnelson699)\
**Post date:** [July 9, 2022, 7:04pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/8 "2022-07-09T19:04:21Z")

</div>

Yeah, I just took the variables out and manually put in the target and source mailboxes.

```auto
New-MailboxRestoreRequest -SourceMailbox testgroup2@outlook.com -TargetMailbox testshared@outlook.com -AllowLegacyDNMismatch -Verbose

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:17pm UTC](https://forums.powershell.org/t/trying-to-migrate-group-emails-to-shared-mailbox/19836/9 "2024-05-16T20:17:46Z")

</div>


