0

I wish to script the procedure to bring the mailbox back from Dumpster. In my normal procedure I do as below

'$Dumpster = Get-MailboxServer | Get-Mailboxstatistics'
'$Dumpster | ? {$_.DisplayName -like "Display Name"} | ft DisplayName, MailboxGUID, ItemCount, TotalItemSize, Database -AutoSize




DisplayName     MailboxGuid                          ItemCount TotalItemSize                  Database
-----------     -----------                          --------- -------------                  --------
Display Name 437cdd37-d54c-4f96-aae0-8d523707ca41         1 3.891 KB (3,984 bytes)         DB53 '

and then create an emailbox just like the deleted one and recover it from dupmster as below

'New-MailboxRestoreRequest -SourceDatabase "DB53" -SourceStoreMailbox "437cdd37-d54c-4f96-aae0-8d523707ca41" -TargetMailbox dname@domain.tld -AllowLegacyDNMismatch'

So the MailboxGUID and Source-mailboxDB I wish to get them into two variables. How can I do it?

yagmoth555
  • 16,758
  • 4
  • 29
  • 50
CanBuyukburc
  • 13
  • 1
  • 6

1 Answers1

0

Try to use this

$Dumpster = Get-MailboxServer | Get-Mailboxstatistics | ? {$_.DisplayName -like "name"}

Then replace the specific value with $Dumpster.DisplayName $Dumpster.MailboxGUID

joyceshen
  • 89
  • 3
  • I solved it like below ' $Anzeigename = Read-Host -Prompt "Geben den genauen Anzeigenamen ein" $Dumpster = Get-MailboxServer | Get-Mailboxstatistics $tere = ($Dumpster|? {$_.DisplayName -like $Anzeigename|Sort ItemCount}).MailboxGuid $MBguid = ($tere -split "`n")[1] $NDBname = ($Dumpster|? {$_.DisplayName -like $Anzeigename|Sort ItemCount}).DatabaseName $DBname = ($ndbname -split "`n")[1] $TargetMBox = Read-Host -Prompt "geben Ziel-Mail-Adresse ein" New-MailboxRestoreRequest -SourceDatabase "$DBname" -SourceStoreMailbox "$MBguid" -TargetMailbox $TargetMBox -AllowLegacyDNMismatch' – CanBuyukburc Apr 30 '19 at 08:03