Una nueva entrega de formularios en powershell. El siguiente script migra el buzon de un servidor Exchange/O365 a otro servidor Exchange/O365 a través de la conexión MAPI de Outlook.
Delegaremos en Outlook la conexión a ambos buzones Exchange (ya sea on-premise o en la nube).
No hay problema en conectar a dos buzones Exchange en el mismo perfil de Outlook (2010 en adelante), salvo que hay que hacerlo con Outlook cerrado, desde Panel de Control > Correo.
Una vez configurados ambos buzones y abierto Outlook, podemos lanzar el script, que detectara los buzones de tipo Exchange (ExchangeStoreType = 0 o 4) y los añadira a los desplegables para que elijas buzón origen y buzón destino. El script recorrerá todas los almacenes habituales del buzón y moverá los elementos al buzón destino:
|
function Release-Ref ($ref) { ([System.Runtime.InteropServices.Marshal]::ReleaseComObject( [System.__ComObject]$ref) -gt 0) [System.GC]::Collect() [System.GC]::WaitForPendingFinalizers() } #Fin Release-Ref function MigrateContent($sourcefolder,$targetfolder,$breadcrumb) { $items=$sourcefolder.items foreach ($item in $items) { write-host "." -nonewline $item.Move($targetfolder)|out-null } $folders = $sourcefolder.Folders foreach ($folder in $folders) { try{$targetfolder.Folders.Add($folder.Name)} catch{} $Subfolder = $sourcefolder.Folders.Item($folder.Name) $Subfolder2 = $targetfolder.Folders.Item($folder.Name) Write-Host $folder.Name -fore cyan [void]$ListBox.Items.Add(" $breadcrumb\$($folder.Name)") $listBox.TopIndex = $listBox.Items.Count - 1 MigrateContent $Subfolder $Subfolder2 "$breadcrumb\$($folder.Name)" } } ###main### $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition $mailbox=@() $a=""|select id,description;$a.id=9;$a.description="Calendar";$mailbox+=$a $a=""|select id,description;$a.id=10;$a.description="Contacts";$mailbox+=$a $a=""|select id,description;$a.id=16;$a.description="Drafts";$mailbox+=$a $a=""|select id,description;$a.id=6;$a.description="Inbox";$mailbox+=$a $a=""|select id,description;$a.id=12;$a.description="Notes";$mailbox+=$a $a=""|select id,description;$a.id=5;$a.description="Sent";$mailbox+=$a $a=""|select id,description;$a.id=13;$a.description="Tasks";$mailbox+=$a $objOutlook = new-object -comobject outlook.application $n = $objOutlook.GetNamespace("MAPI") $stores=@() $n.Stores|?{'0','4' -contains $_.ExchangeStoreType}|%{$stores+= $_.displayname} #Formulario [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void][System.Reflection.Assembly]::loadwithpartialname("System.Drawing") $Form1 = New-Object System.Windows.Forms.Form $Form1.ClientSize = "400, 400" $Form1.text="SistemasWin.com | Mailbox Migration by Outlook" $Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe") $Form1.Icon = $Icon $Form1.backcolor=[System.Drawing.Color]::GhostWhite $Form1.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedSingle $Form1.maximizebox = $false $Form1.minimizebox = $false #cabecera $base64ImageString="iVBORw0KGgoAAAANSUhEUgAAAZAAAABVCAIAAADojyUoAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAGmpJREFUeNrsXQl4VNXZzmT2fU0yWSb7SgIkIUAAUYFfRUGMgqL5kUW0UhYtttoWqvavS31stYobLlArVoxQFhVFQKiIbAlbQiArCSFk3/dMZpL/S8am4Z6TmcnMzUwC3/vk4Qk3d+69c+4573m/73zfdzjK1bs9EAgEYjTAE5sAgUAgYSEQCAQSFgKBQMJCIBAIJCwEAoFAwkIgEEhYCAQCgYSFQCAQSFgIBAIJC4FAIJCwEAgEAgkLgUAgYSEQCAQSFgKBQCBhIRAIJCwEAoFAwkIgEAgkLAQCcR2BN3KplMPRK0Vj/ORBWklti3HXmTJ8WwgEEtZIAdeTE+Mr91OJQ3XS8QZlqLc0QCX2V4vhT/svVCFhIRAIdxKWQSMe46uI8JFF+si85EKtTAg8JeShlYpAINxKWByOhz/IJZUYSCrcRxaslfqrRUBVeoXIrqf05OCrQiAQw0VYwFAGtSRKLxvjpwABZdBI4BedTIAtjkAg3ExYXE+OVioI9ZJG6nt95EBM8G+0Xq5XirCJEQiEmwlLLRF4yQUhOinop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9qXUEir/9fGdhVTI62wBIM4eugRv+yHdVAj9ai+S/tv7a8Wr54ZxiZhJQSqyMKY5Q0dD75/YteZsswB4WRnShr2ZFY8lZZJvc7KGWFOxsVeZyhraKcW9r+bFo443AP1JlqxZreUEhwtMJld4ekX8Ch7BTJY1WXzB7Xucwdt7Yi68kDdowh4/8V77apqZ4Ft6yMpWL32tog1n51lGskdpqWbM4CDYnwVEgG3pdN0tLB2sF3Vbo7UjfGTYy8fiJoWIzDCvHgmPSWHakJ00qIa1zmPYv0USbRtU9OL7V0X7xmWGX1Eg+ohErMdoqwQ8UhTnZG/BRKMJAg+z5PP5XSxKvjI7Fe4NbVgFJVCV396Fo5vSI0nxemrC8Z2d3v8/adiFhSWhbOo+7t49HmstmWU/uPo5X+dumplD0hQfa4vmj7y8R1tLVUrE7h4O4x58X5kPtfl2rYMuwmL01vP88ba5Z0acEAGWjsJDW0jhorGzmvtUBOZ0QVMx27WhIjPJR8Gblxv9/6JpQ3taemlz+7MJr1yoN1eWzg21Y5ubxdhxfjKn7o9wuEag7+5I1KvFHkgCBzKqaZmO9+f5O+yJD6VhE+tvApkOli1RXJ4AFk5WTBPMNrq2FyupUhgag04Z+BLGzil1wbHtXaaWwnfmVoqoO464zC85AIyTaWuxUhd0aamxFrqLH5wuOjPe3IoTMThgPiyWU/F3l4yLVz77qIEBzYvWjI1KCXBD+UVFWUN7dTUMzAJZw6+iQDr8orcocRo7v785JXBPkLtjmKBU9YQNQrMGTgQwDmkjVSLatrIk6P0MnYrnVL3VWIExHR0ma8QJRnA7IrwYTMIOdxbRi6aFde2UneopjZjv3v+tX357/9AKWgBxu/rC8fNterD/X8BBgCrfbWaegNtdAAAAABJRU5ErkJggg==" $imageBytes = [Convert]::FromBase64String($base64ImageString) $ms = New-Object IO.MemoryStream($imageBytes, 0, $imageBytes.Length) $ms.Write($imageBytes, 0, $imageBytes.Length); $logo = [System.Drawing.Image]::FromStream($ms, $true) $pictureBox = new-object System.Windows.Forms.PictureBox $pictureBox.Location = new-object System.Drawing.Point(0,0) $pictureBox.Size = new-object System.Drawing.Size(400,85) $pictureBox.TabStop = $false $pictureBox.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::StretchImage $pictureBox.image=$logo $Form1.Controls.Add($pictureBox) #linea $mypen = new-object Drawing.Pen black $mypen.width = 1 $formGraphics = $Form1.createGraphics() $Form1.add_paint({$formGraphics.DrawLine($mypen, 0, 85, 400, 85)}) #source $objLabel1 = New-Object System.Windows.Forms.Label $objLabel1.Location = New-Object System.Drawing.Point(5,100) $objLabel1.Size = New-Object System.Drawing.Size(50,20) $objLabel1.Text = "Source" $Form1.Controls.Add($objLabel1) $objComboBox1 = New-Object System.Windows.Forms.ComboBox $objComboBox1.Location = New-Object System.Drawing.Point(60,100) $objComboBox1.Size = New-Object System.Drawing.Size(300,20) $objComboBox1.Name = "source" $Form1.Controls.Add($objComboBox1) $objComboBox1.items.addrange($Stores) $objComboBox1.add_selectedindexchanged({ $Form1.Controls.Item("target").text="" $remainingstores=$stores|?{$_ -ne $Form1.Controls.Item("source").text} $objComboBox2.Items.clear() $objComboBox2.items.addrange($remainingstores) }) #target $objLabel2 = New-Object System.Windows.Forms.Label $objLabel2.Location = New-Object System.Drawing.Point(5,130) $objLabel2.Size = New-Object System.Drawing.Size(50,20) $objLabel2.Text = "Target" $Form1.Controls.Add($objLabel2) $objComboBox2 = New-Object System.Windows.Forms.ComboBox $objComboBox2.Location = New-Object System.Drawing.Point(60,130) $objComboBox2.Size = New-Object System.Drawing.Size(300,20) $objComboBox2.Name = "target" $Form1.Controls.Add($objComboBox2) #boton $button = New-Object Windows.Forms.Button $button.Location = "60, 160" $button.Size = "300,20" $button.BackColor = [System.Drawing.Color]::Gainsboro $button.text="Migrate Mailbox" $Form1.Controls.Add($button) $button.Add_Click({ if($Form1.Controls.Item("source").text -eq '' -or $Form1.Controls.Item("target").text -eq ''){write-host "select source and target mailboxes"} else{ $this.enabled=$false $ListBox.Items.clear() $mailbox|%{ write-host $_.description -fore magenta [void]$ListBox.Items.Add("Migrating $($_.description)...") $listBox.TopIndex = $listBox.Items.Count - 1 #[System.Windows.Forms.Application]::DoEvents() $sourcestore=$n.Stores.Item($Form1.Controls.Item("source").text) $sourcefolder=$sourcestore.GetDefaultFolder($_.id) $targetstore=$n.Stores.Item($Form1.Controls.Item("target").text) $targetfolder=$targetstore.GetDefaultFolder($_.id) MigrateContent $sourcefolder $targetfolder $_.description } [void]$ListBox.Items.Add("Finished!") $listBox.TopIndex = $listBox.Items.Count - 1 $this.enabled=$true } }) $ListBox = New-Object System.Windows.Forms.Listbox $ListBox.Location = "60, 190" $ListBox.Size = "300,200" $ListBox.BackColor = [System.Drawing.Color]::GhostWhite $listbox.font=new-object System.Drawing.Font("Trebuchet MS",9,1,3,0) $ListBox.borderstyle = 0 #0=sin borde, 2=borde 1=hundido $Form1.Controls.Add($ListBox) #muestro el formulario $Form1.Add_Shown({$Form1.Activate()}) [void] $Form1.ShowDialog() write-host "bye bye" $a=release-ref $objOutlook $a=release-ref $n
Comentarios
Publicar un comentario