by Zadnak at 2013-04-09 14:38:52
Hi all,by DonJ at 2013-04-09 23:33:56
We are about to migrate to a new domain and I need to export all mailboxes to pst of inactive users. We plan to delete the users off Exchange after they have been archived. I was able to generate a report of the inactive users using this command:Get-Mailbox | Get-MailboxStatistics | Where {($.LastLogonTime -lt (get-date).adddays(-60))} |export-csv z:\users_older_than_60.csv
I was wondering what command I need to run next to mass export to pst those users. I’m working with Exchange 2010 for this.
Thanks in advance!
So, you’re after the Export-Mailbox command, I suppose. Use Get-Mailbox to get the maiboxes you want, pipe them to Export-Mailbox, and use its -PSTFolderPath to specify a destination folder.by Zadnak at 2013-04-10 10:29:45
So my command should beby Kottees at 2013-04-11 02:29:56Get-Mailbox | Get-MailboxStatistics | Where {($
.LastLogonTime -lt (get-date).adddays(-60))} | New-MailboxExportRequest -Filepath z:\pstfiles
Is that enough for Powershell to understand what I want? I’m AWFUL with sintax, so that’s why I’m asking.
Hi, Try this.by Zadnak at 2013-04-13 15:45:09
foreach ($i in (Get-Mailbox | Get-MailboxStatistics | Where {($.LastLogonTime -lt (get-date).adddays(-60))})) { New-MailboxExportRequest -Mailbox $i -FilePath "\Exports$($i.Alias).pst" }
I get this when running ^that command:by ArtB0514 at 2013-04-15 08:45:53Cannot process argument transformation on parameter ‘Mailbox’. Cannot convert the "Microsoft.Exchange.Data.Mapi.MailboxStatistics" value of type "Microsoft.Exchange.Data.Mapi.MailboxStatistics" to type "Microsoft.Exchange.Configuration.Tasks.MailboxOrMailUserIdParameter".
+ CategoryInfo : InvalidData: ( [New-MailboxExportRequest], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MailboxExportRequest
Thanks for the help!
You just need to move the Where-Object clause before the Get-MailboxStatistics call so that the Mailbox gets returned and not the statistics object at the end of the pipeline.by Zadnak at 2013-04-15 14:43:18foreach ($i in (Get-Mailbox | Where-Object {($
| Get-MailboxStatistics).LastLogonTime -lt (Get-Date).AddDays(-60)})) {do-export-here}
Running ^that command, I getby ArtB0514 at 2013-04-15 16:28:45Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) ,
PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
Ah, so. I keep forgetting about that. Try it this way and see if it works.by ArtB0514 at 2013-04-16 06:28:28foreach ($I in (Get-Mailbox | Where-Object {(Get-MailboxStatistics $.Name).LastLogonTime -lt (Get-Date).AddDays(-60)})) {do-export-task-here}
I don’t have access to Exchange right now, so can’t really check this. I’ll think about it more tonight and see how it works when I get to the office tomorrow.
Hmmm. Still gets the running pipeline error. Oh, well, this way isn’t very efficient, but it does work:by Adom503 at 2013-04-26 02:57:40$Day60 = (Get-Date).AddDays(-60)
$Mailboxes = Get-Mailbox -ResultSize Unlimited
$Mailboxes = $Mailboxes | Where-Object {(Get-MailboxStatistics $.Name).LastLogonTime -lt $Day60}
foreach ($I in $Mailboxes) {do-export-task-here}
Whenever I used powershell scripts for the inactive users mailboxes or disconnected mailboxes, i came in trouble. Now thing is that what I did to overcome here, just deployed a small edb pst application that did this job smoothly. You may check:by Zadnak at 2013-05-01 07:18:25
http://www.pcvita.com/edb-converter.html
Thanks!!!
[quote="ArtB0514"]Hmmm. Still gets the running pipeline error. Oh, well, this way isn’t very efficient, but it does work:$Day60 = (Get-Date).AddDays(-60)
[/quote]
$Mailboxes = Get-Mailbox -ResultSize Unlimited
$Mailboxes = $Mailboxes | Where-Object {(Get-MailboxStatistics $_.Name).LastLogonTime -lt $Day60}
foreach ($I in $Mailboxes) {do-export-task-here}
This worked perfectly! Thank you very much for your help.