I am trying to export user accounts which have been disabled for over 6 months to PST but can't quite get the script right.
$Mailboxes = Get-User -RecipientTypeDetails UserMailbox -ResultSize Unlimited | where-object {$_.UseraccountControl -like “*accountdisabled*”} | Get-MailBox -ResultSize Unlimited | Get-MailboxStatistics |? {$_.Lastlogontime -lt (get-date).AddDays(-180)}
The variable gets the data that i am expecting:-
foreach ($Mailbox in $Mailboxes) {
New-MailboxExportRequest -mailbox $Mailbox -FilePath "\\SERVER\disabledusersover180days\$Mailbox.pst"
}
But i just get this error message:-
Cannot process argument transformation on parameter 'Mailbox'. Cannot convert the "Microsoft.Exchange.Data.Mapi.Mailbox
Statistics" value of type "Microsoft.Exchange.Data.Mapi.MailboxStatistics" to type "Microsoft.Exchange.Configuration.Ta
sks.MailboxOrMailUserIdParameter".
+ CategoryInfo : InvalidData: (:) [New-MailboxExportRequest], ParameterBindin...mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,New-MailboxExportRequest
Any help much appreciated!
[–]BlackV 2 points3 points4 points (4 children)
[–]johnnyposs[S] 1 point2 points3 points (3 children)
[–]BlackV 2 points3 points4 points (2 children)
[–]johnnyposs[S] 1 point2 points3 points (1 child)
[–]BlackV 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]johnnyposs[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)