here is the code I put :
$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 **
Here is the error message:
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
Olaf
3
Did you check the content of the variable you want to use? Try to use the subexpression operator.
how do/would I use the sub-expression operator?
Olaf
5
Have you at least tried to google it?
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
Olaf
7
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.
Yeah, I just took the variables out and manually put in the target and source mailboxes.
New-MailboxRestoreRequest -SourceMailbox testgroup2@outlook.com -TargetMailbox testshared@outlook.com -AllowLegacyDNMismatch -Verbose